ExtJS -Отправка формы

У меня есть код:

win = desktop.createWindow({
    id: 'admin-win',
    title: 'Add administration users',
    width: 740,
    height: 480,
    iconCls: 'icon-grid',
    animCollapse: false,
    constrainHeader: true,
    xtype: 'form',
    bodyPadding: 15,
    url: 'save-form.php',
    items: [{
        xtype: 'textfield',
        fieldLabel: 'Field',
        name: 'theField'
    }],

    buttons: [{
        text: 'Submit',
        handler: function () {
            var form = this.up('form').getForm();
            if (form.isValid()) {
                form.submit({
                    success: function (form, action) {
                        Ext.Msg.alert('Success', action.result.message);
                    },
                    failure: function (form, action) {
                        Ext.Msg.alert('Failed', action.result ? action.result.message : 'No response');
                    }
                });
            }
        }
    }]
});

И кнопки не работают. Это создает ошибку -this.up ('форма' )не определена. Как я могу вызвать getForm ()в таком коде?

ОБНОВЛЕНИЕ :Спасибо за очень быстрый ответ! Я изменил ваш код для своих нужд, вот он, и он работает с примером рабочего стола:

win = desktop.createWindow({
    id: 'admin-win',
    title: 'Add administration users',
    width: 740,
    iconCls: 'icon-grid',
    animCollapse: false,
    constrainHeader: true,
    items: [{
        xtype: 'form',
        bodyPadding: 15,
        url: 'save-form.php',
        items: [{
            xtype: 'textfield',
            fieldLabel: 'Field',
            name: 'theField'
        }],

        buttons: [{
            text: 'Submit',
            handler: function () {
                var form = this.up('form').getForm();
                if (form.isValid()) {
                    this.up().up().submit({
                        success: function (form, action) {
                            Ext.Msg.alert('Success', action.result.message);
                        },
                        failure: function (form, action) {
                            Ext.Msg.alert('Failed', action.result ? action.result.message : 'No response');
                        }
                    });
                }
            }
        }]
    }]
});
6
задан Darin Kolev 13 May 2013 в 00:20
поделиться