There is a button, when i click that there will be a call to the Server, and i will get a JSON response.
This JSON response will contain a string similar to
{
"value": "Success",
"information": {
"firstName": "kei",
"surname": "chan"
}
}
The value field in the JSON will be either SUCCESS or FAIL. So if it is success, i will have to navigate to another view and display the firstName and surname.
I will need to pass the values firstName and lastName to the other view if so.
How can i pass the values of firstName and lastName in senchaTouch/cordova ?
Code:
the button
xtype:'button',
id:'when_button_click',
text:'Send',
ui:'confirm',
Controller class
extend: "Ext.app.Controller",
config: {
refs: {
newNoteBtn: "#when_button_click"
},
control: {
newNoteBtn: {
tap: "onNewNote"
}
}
},
onNewNote: function () {
var values = Ext.getCmp('form').getValues();
console.log("inside onNewNote function");
Ext.Ajax.request({
url: 'http://call.com/the_webservice',
params : values,
failure: function (response) {
var text = response.responseText;
console.log("fail");
}, success: function (response) {
var text = response.responseText;
console.log("success");
}
});
}
// init and launch functions omitted.
});
You can simply add additional properties into the new View object that the controller is creating. For example if the controller handler function is “pushing” a new view like so
Then the view can access these properties in the initialize() function.
For the code sample — in the “mylistView” initialize() section you access these properties as