Implementing copy clipboard

Maybe a stupid question, but how do I implement this js.script in anvil?

This should help.

To implement this particular solution, you can just add this js code to your Native Libraries in Anvil Editor and call it as mentioned in the post

1 Like

Thank you very much, but I get always the error in my ā€œeditFormā€:
attributeError: ā€˜editFormā€™ object has no attribute ā€˜call_jsā€™

Actually you will need to replace that line with anvil.js.call

import anvil.js
anvil.js.call("copyclip", self.lbl_odscode.text)
1 Like
import anvil.js

def btn_chrcopy_click(self, **event_args):
    anvil.call_js("copyclip", self.lb_id.text)

but I still get the error
AttributeError: module ā€˜anvilā€™ has no attribute ā€˜call_jsā€™


import anvil.js

def btn_chrcopy_click(self, **event_args):
    anvil.js.call("copyclip", self.lb_id.text)

Itā€™s anvil.js.call, not anvil.call_js

OK thank you, sorry my mistake. It is working fine now.
Only 1 question : I added your js.script to the standard-page.html page of this app. Is this OK?

The Native Libraries section is the best place for your custom Javascript and CSS. That way if you replace the standard page HTML with another one to change the look and feel, you donā€™t need to worry about your custom Javascript.

3 Likes

OK thanks for this quick reply.