سؤال

I have added an actioncolumn inside my grid. On the actioncolumn handler(click) I want to use the zeroclipboard library to copy the text to the clipboard.

I have encountered a few problems. Sometimes I need multiple clicks on my actioncolumn to trigger the copy. Sometimes I have to refresh the page to trigged the copy.

My actioncolumn handler:

handler: function(view, rowIndex, colIndex, item, e, record, row){

   ZeroClipboard.config({moviePath: 'resources/js/zeroclipboard/ZeroClipboard.swf'});
   var client = new ZeroClipboard(e.target);

   client.on('load',function(client) {

    client.on('datarequested', function(client) {
        client.setText("Text to be copied");
    });


    client.on('complete', function(client, args) {
       // alert("Copied text to clipboard: " + args.text);
       Myapp.app.getController('UiNotification').showNotification("Link copied to clipboard");
    });   
});
}

One of possible workarounds is to set the copy text on mouseover but the actioncolumn does not have any other events except the handler.

Please help

هل كانت مفيدة؟

المحلول

So the actioncolumn handler is a click? If so, then yes, dynamically attaching ZeroClipboard during a click event is too late. At best, it would be available during a 2nd click; at worst, it could be delayed several clicks (time-wise) as it also needs to asynchronously load the ZeroClipboard SWF file.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top