Domanda

I have read the wiki in the plugin page, searched and researched but i still cant get zropClipboard to work...

  • i am not getting any javascript error...
  • the text is being alerted correctly but wont get to my clipboard

This is my code:

var clip = new ZeroClipboard($('.copythis'));

clip.on('load', function(client) {
    // alert( "movie is loaded" );
});

clip.on('complete', function(client, args) {
    alert("Copied text to clipboard: " + args.text );
});

clip.on('mouseover', function(client) {
    // alert("mouse over");
});

clip.on('mouseout', function(client) {
    // alert("mouse out");
});

clip.on( 'mousedown', function(client) {
    var copythis = '#' + $(this).attr('cliptarget');
    var copytext = $(copythis).val();
    client.setText(copytext); // ALSO TRIED: clip.setText(copytext);
    alert(copytext); // THIS ALERTS THE RIGHT TEXT
});

clip.on( 'mouseup', function(client) {
    // alert("mouse up");
}); 

I really want to get it to work... Would apreaciate your help.

È stato utile?

Soluzione

Try replacing mousedown with dataRequested.

On mousedown, the flash object will check and see if the clipText has been set. If it hasn't, then it will fire off a dataRequested event. If the html object has data-clipboard-text or data-clipboard-target then ZeroClipboard will take care of getting the data. However if it hasn't been set, then it will be up to you to clip.setText from that method. Which will complete the loop.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top