ja mam:ExtJS - Formularz złożyć kod
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');
}
});
}
}
}]
});
i przyciski nie działają. Tworzy błąd - this.up ("formularz") jest niezdefiniowany. Jak wywołać funkcję getForm() w takim kodzie?
AKTUALIZACJA: Dzięki za szybką odpowiedź! I zmodyfikowany kod dla moich potrzeb, to jest to, i to działa z pulpitu Przykład:
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');
}
});
}
}
}]
}]
});
Jest to kompletny kod? Co robi desktop.createWindow? Pytam o to, ponieważ wydaje się, że próbujesz utworzyć okno, ale używając opcji Ext.form.Panel. – davidbuzatto
Jest oparty na przykładzie Desktopa ExtJS. Chcę utworzyć okno tylko z formularzem. –
Skopiujesz ten kod? – davidbuzatto