Copy button in view - is there how to do it?

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
marcelo
Posts: 10
Joined: 2020-07-29 15:26

Copy button in view - is there how to do it?

Post by marcelo » 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!

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Copy button in view - is there how to do it?

Post by pbottcher » 2021-05-28 20:47

Hi,

maybe I did not get completely your requirement, but you want to copy in the TV from one field to another one via a button?
How would you know for which row you want to copy.
Also in the TV usually you do not have something like a "Save" action.

In your sample you copy the field, but it is not yet saved to the database, so if the user quits the page without saving, your copied field is not filled.
How shall this be handled in the TV?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Post Reply