0

I'm trying to reload/refresh the complete aura component for some actions like after hit the submit button in component.

Currently i'm refreshing the complete page by using location.reload(); . Suggest me is there any better option to reload the custom aura component based on some action.

1

1 Answer 1

0

There are few things you can do without using location.reload if you just want to fetch the data back from server.

  1. You can fetch the data from server again and update the UI after submit operation is success.

  2. You can recall doInit method, so if your doInit is fetching the data again it would do the same.

For eg:

If you are calling server side from init

({
    init: function (cmp, event, helper) {
        helper.fetchDataFromServer(cmp, event, helper);
    },
});

({
    fetchDataFromServer : function (cmp, event, helper) {
        let findContacts = cmp.get('c.fetchContact');
        findContacts.setCallback(this, function (response) {
            // Your action
        });
        $A.enqueueAction(findContacts);
    }
});

Then in handleSubmit method just recall server again.

    handleSubmit: function (cmp, event, helper) {
        // Do your stuff
        helper.fetchDataFromServer(cmp, event, helper);
    }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .