0

Heyo all,

I am working on a Lightning Community. I need to detect whenever the user goes to the main page (clicking page logo, home ling, whatever...). I tried the following events :

<aura:handler event='force:refreshView' action='{!c.myAction}'/>    
<aura:handler event='force:navigateHome' action='{!c.myAction}'/>

But neither of these do what I need, and the documentation explained me why. Is there any way to detect when the user is redirected to a given page ?

Thanks

0

I tried enabling Salesforce lightning Inspector to see which event is fired when you click the home button. The event fired is siteforce:viewChanged

Home Click Event Fired

Then I tried adding a listener for that event ,

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:handler event="siteforce:viewChanged " action="{!c.doRedirect}"></aura:handler>
</aura:component>

When I try to save it, I get compile time error:

Failed to save ViewChangeEvent.cmp: Invalid Descriptor Format: siteforce:viewChanged [EVENT]: Source

It looks like siteforce:viewChanged is private for Salesforce namespace and we cannot listen to it, thus I don't think there a way todetect when the user is redirected to a given page.

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.