Kliver Max
Kliver Max

Reputation: 5299

ExtJs datepicker listener

I have datefield on my form:

        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');
                }
            }
        }]
    });

But whe i start application i get error:

 SyntaxError: missing formal parameter  

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

I cant use listeners when i create datefield like this, i gonna use variable to create datefield?

Upvotes: 1

Views: 5352

Answers (2)

Arun P Johny
Arun P Johny

Reputation: 388316

You have a syntax error, you cannot use this as a parameter name change it to field or any other name

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');
            }
        }
    }]
});

Upvotes: 2

Musa
Musa

Reputation: 97672

You cant use this as a parameter name, use something else like self or me.

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

Upvotes: 1

Related Questions