Question

I'm trying to implement zclip to copy input's content into clipboard. There is 20 text inputs on the page like this:

<input type="text" value="content to copy..." />
<input type="text" value="another content to copy..." />

And I came up with this jQuery code:

jQuery(function() {
  jQuery("input[type=text]").click(function() {
    var link = jQuery(this).val();
    jQuery(this).zclip({
        path: '/img/ZeroClipboard.swf',
        copy: link
    });
  });
});

In the Javascript console I get this error: Uncaught TypeError: Property '$' of object [object DOMWindow] is not a function.

How can I get this working? Thx

Was it helpful?

Solution

Seems as if you use jQuery in noConflict mode. ZClip assumes that this is not the case and tries to extend the '$'. I just replaced every '$' in the jquery.zclip.js with 'jQuery' and the error message disappeared. If there is another way to run zClip in noConflict mode let me know.

OTHER TIPS

Use each instead of click and use a function to return the link value

jQuery(function() {
  jQuery("input[type=text]").each(function() {
    var link = jQuery(this).val();
    jQuery(this).zclip({
        path: '/img/ZeroClipboard.swf',
        copy: function(){return link;}
    });
  });
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top