Skip to content

Instantly share code, notes, and snippets.

@allusis
Last active August 28, 2018 21:03
Show Gist options
  • Save allusis/d132f9926c2f85f6ed8f34908129d2eb to your computer and use it in GitHub Desktop.
Save allusis/d132f9926c2f85f6ed8f34908129d2eb to your computer and use it in GitHub Desktop.
Lightning Back Button
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global">
<aura:attribute name="wrapperClass" type="String" default="page-controls" />
<aura:attribute name="buttonTitle" type="String" default="Go Back" />
<div class="{!c.wrapperClass}">
<button class="btn-hed btn-back" onclick="{!c.redirect}">{!c.buttonTitle}</button>
</div>
</aura:component>
<design:component>
<design:attribute name="wrapperClass" label="Wrapper CSS Class"/>
<design:attribute name="buttonTitle" label="Button Title"/>
</design:component>
({
redirect: function (){
var url = window.location.href;
var value = url.substr(0,url.lastIndexOf('/') + 1);
window.history.back();
return false;
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment