-
22 Feb 2008 7:44 AM #1
need some TEXTAREA events
need some TEXTAREA events
im using phpBB site, where there is post page with textarea, which in "normal" html has following look
<textarea id="somename" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);">
id like to replicate this textarea using EXT, I have the form up and working, with the part of formpanel look like this :
var top = new Ext.FormPanel({
id:'formularpanel',
labelAlign: 'top',
bodyStyle:'padding:5px 5px 0',
width: 480,
items: [{
xtype:'textarea',
id:'prispevek',
fieldLabel:'Text',
anchor:'90% 80%'
}],
...
How do I attach the onclick, onkeyup and onselect events to it ? as it seems to me, from the documentation, not all of these events are avaiable on the textarea from EXT, but when I inspected the code, it does create a normal textarea at the end, so i should be able to make those events work, I just dont know how.
I tried the "listeners", "xxxx.on", but none of my tries did work
Can you please help me, how to attach those three event listeners to textarea ?
thank you
-
22 Feb 2008 7:45 AM #2
Try binding to the el directly:
Code:myTextArea.getEl().on('normalDomEvent', ...);
-
22 Feb 2008 7:58 AM #3
for some reason I cant make it work
I tried
(tried also some variations like .getCmp('prispevek').on( ... etc.)Code:Ext.getCmp('prispevek').getEl().on('keyup', alert('b'));
to place before or behind
but the only result was, that the message has been fired immediatly once the window has been opened, no matter what event i tried it to bindCode:if(!win){ win = new Ext.Window({ id:'formwindow', title: 'New post', layout:'fit', width:500, height:400, closeAction:'close', plain: true, tbar:tb, items: [top] }); } win.show(this);
-
25 Feb 2008 1:01 AM #4
ok, i made a mistake somewhere, this is the correct syntax ...
this has to be AFTER the win.show() command so the items are rendered already ...Code:Ext.getCmp('prispevek').getEl().on('change', function(e) { alert('b'); }); Ext.getCmp('prispevek').getEl().on('keyup', function(e) { alert('c'); }); Ext.getCmp('prispevek').getEl().on('click', function(e) { alert('a'); });
-
25 Feb 2008 1:13 AM #5Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 43
Or use the render event, e.g.
Code:{ id: 'prispevek', xtype: 'textarea', ... listeners: { render: function(c) { c.el.on({ change: function(e) { alert('change'); }, keyup: function(e) { alert('keyup'); }, click: function(e) { alert('click'); }, scope: c }); } } }


Reply With Quote