Created
May 1, 2019 16:55
-
-
Save arun12209/c571fbdf06ccaa0e54edef10783f1c08 to your computer and use it in GitHub Desktop.
copyToClipboardCmpController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
doInit : function(component, event, helper) { | |
//get the object details from apex | |
helper.getsObjectName(component,event,helper); | |
}, | |
copyLink:function(component,event,helper){ | |
//dynamically creating html component | |
var hiddenInputEle = document.createElement("input"); | |
//get the title of clicked element (record link) | |
let val = event.getSource().get("v.title"); | |
//set value attribute as actual record link | |
hiddenInputEle.setAttribute("value", val); | |
//append the element in the document body | |
document.body.appendChild(hiddenInputEle); | |
// select the content | |
hiddenInputEle.select(); | |
// Execute the copy command | |
document.execCommand("copy"); | |
document.body.removeChild(hiddenInputEle); | |
//Show toast message after link copied in the clipboard | |
var toastEvent = $A.get("e.force:showToast"); | |
toastEvent.setParams({ | |
mode: 'sticky', | |
title: 'Success!', | |
message: 'Link has been copied to clipboard.', | |
type: 'success' | |
}); | |
toastEvent.fire(); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment