javascript - why my listeners does not work on extjs? - Stack Overflow

here is the code and also i want onPaste event instead of click but nothing workingvar mpan0 = new Ext.

here is the code and also i want onPaste event instead of click but nothing working

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");
});

here is the code and also i want onPaste event instead of click but nothing working

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");
});
Share Improve this question edited Jul 3, 2010 at 15:35 Sean Kinsey 38k7 gold badges54 silver badges71 bronze badges asked Jul 3, 2010 at 15:29 Amit SharmaAmit Sharma 1,9885 gold badges24 silver badges35 bronze badges 0
Add a ment  | 

3 Answers 3

Reset to default 6

Ext.form.TextField does not have a 'click' event. You can see the events it does support at:

http://www.sencha./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:

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:

http://www.sencha./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

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");
        }
    }
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744164563a4561244.html

相关推荐

  • javascript - why my listeners does not work on extjs? - Stack Overflow

    here is the code and also i want onPaste event instead of click but nothing workingvar mpan0 = new Ext.

    8天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信