6

I need to know when a tab is switched. Can I subscribe to an event and get notified?

In my usecase I need to commit pending changes before user switches tabs or at least notify the user. Just need an event or any mechanism to track, the rest is easy on my own.

Is there a way to extend this Standard Component?

I've seen there is also a lightning:tab here https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/lightning_overview.htm but using it will kill the feature to add subcomponents via the App Builder, right?

1

There is a Lightning even when navigation happens by adding aura:locationChange. It fires also when user switches tabs. I believe you can determine if tab has been switched or refreshed by value of

var loc = event.getParam("token");

in the handler for

({
    update : function (component, event, helper) {
        // Get the new location token from the event
        var loc = event.getParam("token");
        // Do something else
    }
})

event

<aura:handler event="aura:locationChange" action="{!c.update}"/>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.