I'm going crazy here! javascript works in develpoment, when I deploy it does not work

I keep trying tweaks and it works in preview, even with ‘debug’ turned off, I then deploy to live and on the live site I either get a syntax error, or the javascript does nothing. its common simple javascript that copyies data from my screen into the clipboard.
myContent = “(ChooseKnowledge’s value’s KnowledgeContent)”;
var tempInput = $().val(myContent).appendTo(‘body’).select();
document.execCommand(‘copy’);

1 Like

I was having the same issue but only when accessing it from a Google Chrome extension. I think for my situation, it is not working because of something Google is potentially blocking.

This is the code I am using:

function copyToClipboard(text) {
  navigator.clipboard.writeText(text)
  .then(() => {
    console.log('Arbitrary text');
  })
  .catch(err => {
    console.error('Failed to copy text: ', err);
  });
}

// Usage
copyToClipboard('Arbitrary text');

i’m not a javascript guy and I’m new to bubble, are you putting all of this in a single javascript call from your bubble app? I tried MS Edge browser and I’m still having the same problem: should this work?(having no error handling and no temporary element on the screen seems ideal).

navigator.clipboard.writeText(“(Choose Knowledge’s value’s KnowledgeContent)”);

I redid mine using navigator.clipboard.WriteText to no avail, still works perfectly in preview, but not at all when I deploy.

So your browser and this feature are having a bit of a tiff? They’re in a complicated kind of relationship. I’d recommend maybe introduce them to an Element or bring in that smooth plugin, the copy/paste plugin from Airdev. Who knows, maybe they’ll hit it off better that way! :man_dancing::computer:

@nocodeventure :joy: Yeah, I was using the plugin before but when updating the plugin to the newest version it breaks. (Version 4 requirement from Bubble) :man_facepalming: I was hoping that I could just drop some code in there to make it work. It works everywhere else for me except the Chrome Extension unfortunately. :cry: