PDA

View Full Version : ZeroClipboard in Ext-js



w4ter
9 Aug 2010, 2:15 AM
Hello!
Somebody, help me to connect ZeroClipboard to EXT.
I have Ext.menu.Menu with item


cellTextItem = new Ext.menu.Item({
text: "CopyToClipboard",
handler: function(){
copyToClipboard(text);
}
})

in IE i simply can do "window.clipboardData.setData("Text", ' ' + text);". In Chrome and Firefox i cant copy it.
Thanks.

Condor
9 Aug 2010, 2:40 AM
What is the problem? Did you follow the ZeroClipboard instructions (http://code.google.com/p/zeroclipboard/wiki/Instructions)?

w4ter
9 Aug 2010, 2:49 AM
Yea i read. My problem thats i'm really newbie in "Web" programming, and i can't understang function glue. If u have extra time, plz help me.

P.S. I understand that i need to get cellTextItem id, but i can't(coz i use ext-js 1.1).

Condor
9 Aug 2010, 3:01 AM
Something like:

var clip = new ZeroClipboard.Client();
clip.setText('');
clip.setHandCursor(true);
clip.addEventListener('mouseDown', function(client) {
clip.setText(Ext.getCmp('myTextArea').getValue());
});
var item = new Ext.menu.Item({
text: "CopyToClipboard",
listeners: {
render: function(c){
clip.glue(c.getEl().id);
}
}
})
(warning: untested code!)

w4ter
9 Aug 2010, 3:13 AM
ext-js 1.1 Ext.menu.Item has no "listeners"(:. Anyway thx 4 try.

Condor
9 Aug 2010, 3:22 AM
If you're using Ext JS 1.1 then you posted in the wrong forum.

And even in Ext JS 1.1 Ext.menu.Item is an Ext.util.Observable, so it does have a listeners config option.