I have tried the following in the fetch
success callback, but it fails and returns false
. This issue occurs in Edge browser.
document.execCommand('copy')
HTML Code:
<div id="toCopy">
new value 12345
<br /><br />
<a href="#">Link</a>
</div>
Backbone JS code:
toCopy = Backbone.Model.extend({});
toCopy.fetch({
"id": "xxx",
}).done(function(resp) {
if (window.getSelection) {
var range = document.createRange();
range.selectNodeContents(document.getElementById("toCopy"));
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
}
document.execCommand("copy");
});