2013-05-15 72 views
1

我有我的表上的DateField:ExtJS的日期选择器监听

 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){ 

当我创建的DateField这样我不能使用监听器,我该怎么使用变量来创建日期字段?

回答

2

你有一个语法错误,你不能使用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'); 
      } 
     } 
    }] 
}); 
+0

呀,谢谢你的回答。 –

1

您不能使用this作为参数名称,请使用其他类似selfme

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