[英]why my listeners does not work on extjs?
here is the code and also i want onPaste event instead of click but nothing working 这是代码,我也想要onPaste事件而不是单击,但是没有任何作用
var mpan0 = new Ext.form.TextField({
name:'mpan[]' ,
value:0 ,
allowblank:false ,
enableKeyEvents:true ,
fieldLabel:'Mpan',
maxLength:2,
width:35
});
mpan0.addListener('click', function(){
alert( "amiy");
});
Ext.form.TextField does not have a 'click' event. Ext.form.TextField没有'click'事件。 You can see the events it does support at:
您可以在以下位置查看它支持的事件:
http://www.sencha.com/deploy/dev/docs/?class=Ext.form.TextField http://www.sencha.com/deploy/dev/docs/?class=Ext.form.TextField
The closest I can think of to what you are seeking is the 'focus' event. 我能想到的与您寻找的最接近的是“焦点”事件。
If you really must have a click event you can try attaching a listener to the field object's fundamental DOM element: 如果确实必须具有click事件,则可以尝试将侦听器附加到字段对象的基本DOM元素:
Ext.form.TextField({
listeners: {
afterrender: function( field ) {
field.getEl().on('click', function( event, el ) {
// do something on click
});
}
}
});
I can't claim to know how successful that will be, however. 但是,我不能声称知道会有多成功。
Documentation on Ext.Element's click event can be found at: 可在以下位置找到有关Ext.Element的click事件的文档:
http://www.sencha.com/deploy/dev/docs/?class=Ext.Element http://www.sencha.com/deploy/dev/docs/?class=Ext.Element
yourtextfield = new Ext.form.TextField({
id:'yourtextfield ',
readOnly : true,
listeners: {'render': function(cmp) {
cmp.getEl().on('click', function( event, el ) {
alert("You click text field");
});
}}
});
This works. 这可行。
ExtJs uses on
, so it should be ExtJs使用
on
,因此应该
mpan0.on("click", function(){
alert("amiy");
});
But you can also add it declaratively 但是您也可以声明性地添加它
var mpan0 = new Ext.form.TextField({
name:'mpan[]' ,
value:0 ,
allowblank:false ,
enableKeyEvents:true ,
fieldLabel:'Mpan',
maxLength:2,
width:35,
listeners: {
"click": function() {
alert("amiy");
}
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.