I am using a custom confirmation dialogue with a textarea(codemirror) on it with some text populated. As code mirrors hides the actual textarea element, firefox is not able to get the data from the hidden textarea field. The definition for the confirmation box goes like below:
var confirmationDialog = MD.ui.dialogs.confirm({
title: title,
text: '',
type: 'dataUri',
dataUri: formUrl,
position: 'center',
buttonForward: {
text: 'Copy',
action: function () {
DataGridExportDialog.CopyToClipboard("#rawXmlImpExp");
}
},
buttonCancel: {
text: 'Cancel',
action: function () {
confirmationDialog.close();
confirmationDialog.destroy();
}
}
});
According to the requirement I have updated the confirm button functionality with copy to clipboard functionality so that on clicking on 'Copy' the text in the textarea should be copied to clipboard. Below is the copyToClipboard().
DataGridExportDialog.CopyToClipboard = function( containerId ) {
/*var textareaData = $('#rawXmlImpExp').val();
var range = document.createRange();
range.selectNodeContents(textareaData);
window.getSelection().addRange(range);*/
var copyTextarea = document.querySelector(containerId);
copyTextarea.select();
try {
var successful = document.execCommand('copy');
raiseMessage('Configuration XML copied to clip board.')
} catch (err) {
raiseWarning('Unable to copy. Please do so manually.');
}}
This implementation works fine on chrome but fails in firefox. Any ideas where my code fails on firefox.