【问题标题】:ExtJs datepicker listenerExtJs 日期选择器监听器
【发布时间】:2013-05-15 04:43:08
【问题描述】:

我的表单上有日期字段:

        var intForm = new Ext.FormPanel({
        width: 350,
        autoHeight: true,
        bodyStyle: 'padding: 10px 10px 10px 10px;',
        labelWidth: 70,
        defaults: {
            anchor: '95%',
            allowBlank: false,
            msgTarget: 'side'
        },items:[{
            xtype:'datefield',
            fieldLabel: 'Выберете дату',
            name: 'intDate',
            anchor:'80%',
            maxValue: new Date(),
            listeners:{
                'change': function(this,newValue,oldValue){
                    alert('newValue');
                }
            }
        }]
    });

但是当我启动应用程序时出现错误:

 SyntaxError: missing formal parameter  

'change': function(this,newValue,oldValue){ 

当我这样创建日期字段时,我不能使用侦听器,我要使用变量来创建日期字段吗?

【问题讨论】:

    标签: extjs extjs3


    【解决方案1】:

    您有语法错误,您不能使用this 作为参数名称,请将其更改为field 或任何其他名称

    var intForm = new Ext.FormPanel({
        width : 350,
        autoHeight : true,
        bodyStyle : 'padding: 10px 10px 10px 10px;',
        labelWidth : 70,
        defaults : {
            anchor : '95%',
            allowBlank : false,
            msgTarget : 'side'
        },
        items : [{
            xtype : 'datefield',
            fieldLabel : 'Выберете дату',
            name : 'intDate',
            anchor : '80%',
            maxValue : new Date(),
            listeners : {
                'change' : function(field, newValue, oldValue) {
                    alert('newValue');
                }
            }
        }]
    });
    

    【讨论】:

      【解决方案2】:

      您不能使用this 作为参数名称,使用其他名称,例如selfme

      'change': function(self,newValue,oldValue){ 
      

      【讨论】:

        猜你喜欢
        • 2011-10-12
        • 2012-01-22
        • 1970-01-01
        • 2013-04-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多