james_D
1 Jul 2012, 9:35 AM
I have a simple form, with 1 label and 1 button. When the user clicks on the button a POST request will be made and i will populate some records on another Window.
1.) The code i have below (which is an example), doesn't use MVC, can someone help me edit the code so that it adheres to MVC standards (Put it to View, Store, and Controller)
2.) How to Navigate to a different view, when the code executes the SUCCESS block ? (Like, populate another view with data) (NAVIGATE TO ANOTHER VIEW, AND DISPLAY RECORDS THAT WAS OBTAINED FROM THE SERVER RESPONSE.)
Ext.create('Ext.form.Panel', {
title: 'Basic Form',
renderTo: Ext.getBody(),
bodyPadding: 5,
width: 350,
// Any configuration items here will be automatically passed along to
// the Ext.form.Basic instance when it gets created.
// The form will submit an AJAX request to this URL when submitted
url: 'save-form.php',
items: [{
xtype: 'textfield',
fieldLabel: 'Field',
name: 'theField'
}],
buttons: [{
text: 'Submit',
handler: function() {
// The getForm() method returns the Ext.form.Basic instance:
var form = this.up('form').getForm();
if (form.isValid()) {
// Submit the Ajax request and handle the response
form.submit({
success: function(form, action) {
//NAVIGATE TO ANOTHER VIEW, AND DISPLAY RECORDS THAT WAS OBTAINED FROM THE SERVER RESPONSE.
},
failure: function(form, action) {
Ext.Msg.alert('Failed', action.result ? action.result.msg : 'No response');
}
});
}
}
}]
});
1.) The code i have below (which is an example), doesn't use MVC, can someone help me edit the code so that it adheres to MVC standards (Put it to View, Store, and Controller)
2.) How to Navigate to a different view, when the code executes the SUCCESS block ? (Like, populate another view with data) (NAVIGATE TO ANOTHER VIEW, AND DISPLAY RECORDS THAT WAS OBTAINED FROM THE SERVER RESPONSE.)
Ext.create('Ext.form.Panel', {
title: 'Basic Form',
renderTo: Ext.getBody(),
bodyPadding: 5,
width: 350,
// Any configuration items here will be automatically passed along to
// the Ext.form.Basic instance when it gets created.
// The form will submit an AJAX request to this URL when submitted
url: 'save-form.php',
items: [{
xtype: 'textfield',
fieldLabel: 'Field',
name: 'theField'
}],
buttons: [{
text: 'Submit',
handler: function() {
// The getForm() method returns the Ext.form.Basic instance:
var form = this.up('form').getForm();
if (form.isValid()) {
// Submit the Ajax request and handle the response
form.submit({
success: function(form, action) {
//NAVIGATE TO ANOTHER VIEW, AND DISPLAY RECORDS THAT WAS OBTAINED FROM THE SERVER RESPONSE.
},
failure: function(form, action) {
Ext.Msg.alert('Failed', action.result ? action.result.msg : 'No response');
}
});
}
}
}]
});