Tôi đã có:ExtJS - Mẫu gửi mã
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');
}
});
}
}
}]
});
Và các nút không hoạt động. Nó tạo ra lỗi - this.up ('form') là không xác định. Làm thế nào tôi có thể gọi getForm() trong mã như vậy?
CẬP NHẬT: Cảm ơn bạn đã trả lời rất nhanh! tôi đổi mã của bạn cho nhu cầu của tôi, đây là nó, và nó làm việc với máy tính để bàn Ví dụ:
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');
}
});
}
}
}]
}]
});
Đây có phải là mã hoàn chỉnh của bạn? Desktop.createWindow làm gì? Tôi đang yêu cầu này bởi vì nó có vẻ như bạn đang cố gắng để crete một cửa sổ nhưng sử dụng Ext.form.Panel tùy chọn. – davidbuzatto
Nó dựa trên Ví dụ về ExtJS Desktop. Tôi muốn tạo cửa sổ chỉ với biểu mẫu. –
Vì vậy, bạn sao chép/dán mã này? – davidbuzatto