Guest User

Untitled

a guest
Dec 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. <aura:component implements="flexipage:availableForRecordHome" access="global">
  2. <lightning:unsavedChanges aura:id="unsaved"
  3. onsave="{!c.handleSave}"
  4. ondiscard="{!c.handleDiscard}" />
  5. <lightning:button label="Make Unsaved Changes" onclick="{!c.makeUnsavedChanges}" />
  6. <lightning:button label="Clear Unsaved Changes" onclick="{!c.clearUnsavedChanges}" />
  7. <aura:component>
  8.  
  9. ({
  10. makeUnsavedChanges: function(cmp, evt, helper) {
  11. var unsaved = cmp.find("unsaved");
  12. unsaved.setUnsavedChanges(true, { label: 'My component name' });
  13. },
  14. clearUnsavedChanges: function(cmp, evt, helper) {
  15. var unsaved = cmp.find("unsaved");
  16. unsaved.setUnsavedChanges(false);
  17. },
  18. handleSave: function(cmp, evt, helper) {
  19. ... my custom save logic
  20. // When the custom save logic has completed the setUnsavedChanges method
  21. // must be called again to return control to the lightning UI
  22. var unsaved = cmp.find("unsaved");
  23. if (something went wrong) {
  24. // return control to the lightning UI while indicating that the content is still unsaved, preventing it from being dismissed
  25. unsaved.setUnsavedChanges(true);
  26. }
  27. else {
  28. // return control to the lightning UI while indicating that the content is saved
  29. unsaved.setUnsavedChanges(false);
  30. }
  31. },
  32. handleDiscard: function(cmp, evt, helper) {
  33. // similar to the handleSave method, but for discarding changes
  34. }
  35. })
Add Comment
Please, Sign In to add comment