0

I have added 'VF Page' in lightning, I just want to refresh the whole page using javascript when event raised in VF page. I have used windw.location.reload(). But its not working.

0

1 Answer 1

4

You can use force:refreshView to force all data to reload, but the page itself still will not reload. This is because Lightning is meant to be a Single Page Application (SPA). Example code from the documentation is as follows:

refresh : function(component, event, helper) {
    var action = cmp.get('c.myController');
    action.setCallback(cmp,
        function(response) {
            var state = response.getState();
            if (state === 'SUCCESS'){
                $A.get('e.force:refreshView').fire();
            } else {
                 //do something
            }
        }
    );
    $A.enqueueAction(action);
}
2
  • I just checked that "window.location.href" and "window.location.reload" return valid values inside a JS controller and when I call window.location.reload(true), the entire page gets refreshed. Not sure why the page will not reload as per your answer. Could you please elaborate? Commented Apr 11, 2018 at 13:13
  • @the_phantom force:refreshView is the recommended approach to "reload" Lightning. This eliminates the 1-3 second loading time. If you want to use location.reload, you can, but I'd advise against it unless you have no other way.
    – sfdcfox
    Commented Apr 11, 2018 at 16:37

You must log in to answer this question.

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