Write to clipboard not copying text to clipboard

Hi,

I used the write to clipboard event assigned to a button to copy dynamic text to the clipboard, however when I come to paste it to check, nothing has been copied. Here is the code:

<button id="btn1" class="btn" dmx-on:click="browser1.writeTextToClipboard('This is the text to be copied when Button is click with some dynamic data '+sc_pck_inactive.data.list_sites[0].site_name)">Button</button>

This works for me so I would suggest a couple of things to check. One is the browser/OS settings to make sure it allows copying to the clipboard. Also check you’ve uploaded all the Wappler scripts to the server.

Check the dev console to see if there are any errors there.

I practically followed the steps outline pad in a previous post and I have included the code generated, I still can’t get it load. is there anything that you see obvious in the code @sitestreet @Teodor
And yes all files have been uploaded. No error is generated on click.

I can’t see anything obvious. Have you cleared your browser cache? I still wonder if it’s a browser setting which is blocking access to the clipboard. Remember that the clipboard is in the OS and not the browser so the two need to be able to communicate with each other.

Still can’t get this to work. I am not sure if this is a BUG.
I am able to use similar functions on other websites allow you to copy text without any issues. So its not a browser settings or OS related.
Can anyone assist? I have provided screenshot and code thats being generation.
Is there a step thats missing? @Teodor?

Wappler has a copy to clipboard event? How do I access this? I could use this in one of my projects and I could test as well.

1 Like

See my example above. You need to add a Browser in app connect and then create a dynamic event to trigger it.

Very cool feature, thanks. Seems to work fine for me.

I haven’t tried with dynamic data yet. I will do more testing.

Have you tried a full publish? Maybe you are missing some files. Anything in the browser console?

I just tried it myself and it seems to work well. Here is my code:

<button id="btn17" class="btn btn-success btn-sm btn-block mt-3" 
dmx-on:click="browser1.writeTextToClipboard('https://www.koparadmin.ca/clientsurvey/'+query.clientkey)">
<i class="fas fa-clipboard"></i>&nbsp; Copy Link to Clipbaord</button>

@brad Are you able to share the header code that reference all the Wappler files? Maybe there is a line that I accidentally deleted when trying to merge two files together

You want to make sure you have this line in your header code …

<script src="/dmxAppConnect/dmxBrowser/dmxBrowser.js" defer=""></script>

And make sure your dmxBrowser.js file has been uploaded to your target.

I definitely have that. I a testing using Safari.
I even tried your code and nothing is copied to the clipboard. this is really strange.
Any ideas?

Did you do a full publish to your target?

Do you have a live link someone else can test to see if it is something local or not?

@brad @sitestreet I found the issue. For some reason it doesn’t work on my local environment, but when I publish it it works? Not sure why that is?

1 Like

What are you using for a local target? Sounds like the dmxBrowser.js file hasn’t been uploaded to the local server. Any errors in the browser console when trying from local target?

I’ll check again. Thanks for your help both. @sitestreet and @brad

1 Like

I think most browsers require https for it to work. On local, you’re unlikely to have this set up

Correct, thanks for explaining. I just discovered that. Yes, I don’t have https setup on my local environment. As long as it works on the live site which it does thank it’s all good. :blush: