Copy button in view - is there how to do it?
Posted: 2021-05-28 14:54
Hey guys! I hope everyone is okay!
Well, I need to create a button to copy the message that is already inside a field, but this button has to be in the view, not in the detail view.
I managed to create inside the detail view as follows:
<button class = "copy"> COPY ABOVE TEXT </button> <BR> <BR>
<script>
var copyTextareaBtn = document.querySelector ('. copy');
copyTextareaBtn.addEventListener ('click', function (event) {
var copyTextarea = document.querySelector ('. textarea');
copyTextarea.select ();
try {
var successful = document.execCommand ('copy');
var msg = successful? 'yea!' : 'no!';
alert ('THE ABOVE TEXT HAS BEEN COPIED!');
// alert ('Text copied?' + msg);
} catch (err) {
alert ('Oops, we were unable to copy the text, it is possible that your browser is not supported, try using Crtl + C.');
}
});
</script>
Any suggestions on how to do this directly in the table without having to enter the detail view?
Hugs!
Well, I need to create a button to copy the message that is already inside a field, but this button has to be in the view, not in the detail view.
I managed to create inside the detail view as follows:
<button class = "copy"> COPY ABOVE TEXT </button> <BR> <BR>
<script>
var copyTextareaBtn = document.querySelector ('. copy');
copyTextareaBtn.addEventListener ('click', function (event) {
var copyTextarea = document.querySelector ('. textarea');
copyTextarea.select ();
try {
var successful = document.execCommand ('copy');
var msg = successful? 'yea!' : 'no!';
alert ('THE ABOVE TEXT HAS BEEN COPIED!');
// alert ('Text copied?' + msg);
} catch (err) {
alert ('Oops, we were unable to copy the text, it is possible that your browser is not supported, try using Crtl + C.');
}
});
</script>
Any suggestions on how to do this directly in the table without having to enter the detail view?
Hugs!