NMFord
8 Jan 2012, 12:20 PM
Hey guys,
I'm trying to pass this Javascript object to my view for displaying information but I can't seem to find a way to access it. In the code below you see I get the object from an ajax request to one of my PHP scripts. Can someone give me some pointers? Thanks!
You can see the line of code I used to try pass it to the view, but in the view I just can't seem to get it working...
Code snippet from my controller:
'search': function (options) {
var panel = BioGene.views.mainView;
panel.setLoading(true, true);
Ext.Ajax.request({
url: 'codeigniter/index.php/search/go/'+options.query,
success: function(response, opts) {
panel.setLoading(false);
var jsonData = Ext.util.JSON.decode(response.responseText);
console.log(jsonData);
if(jsonData.count > 1) {
BioGene.views.searchListView.jsonData = jsonData;
BioGene.views.mainView.setActiveItem(
BioGene.views.searchListView,
{ type: 'slide', direction: 'left' }
);
}
else if((jsonData.count == 1) && (jsonData.return_code = "SUCCESS")) {
alert("One result");
}
else if(jsonData.return_code != "SUCCESS") {
alert("No Results");
}
}
});
},
Code snippet for the view it is being sent to:
BioGene.views.SearchListView = Ext.extend(Ext.Panel, {
layout: 'fit',
type: 'vbox',
align: 'center',
pack: 'center',
scroll: 'vertical',
initComponent: function () {
this.backButton = new Ext.Button({
text: 'Search',
ui: 'normal',
handler: this.onCloseTap,
scope: this
});
this.topToolbar = new Ext.Toolbar({
title: 'Genes',
items: [
//{ xtype: 'spacer' },
this.backButton
]
});
this.dockedItems = [this.topToolbar];
BioGene.views.SearchListView.superclass.initComponent.call(this);
},
onCloseTap: function () {
Ext.dispatch({
controller: BioGene.controllers.bioGeneController,
action: 'index',
slideDirection: 'right'
});
}
});
I'm trying to pass this Javascript object to my view for displaying information but I can't seem to find a way to access it. In the code below you see I get the object from an ajax request to one of my PHP scripts. Can someone give me some pointers? Thanks!
You can see the line of code I used to try pass it to the view, but in the view I just can't seem to get it working...
Code snippet from my controller:
'search': function (options) {
var panel = BioGene.views.mainView;
panel.setLoading(true, true);
Ext.Ajax.request({
url: 'codeigniter/index.php/search/go/'+options.query,
success: function(response, opts) {
panel.setLoading(false);
var jsonData = Ext.util.JSON.decode(response.responseText);
console.log(jsonData);
if(jsonData.count > 1) {
BioGene.views.searchListView.jsonData = jsonData;
BioGene.views.mainView.setActiveItem(
BioGene.views.searchListView,
{ type: 'slide', direction: 'left' }
);
}
else if((jsonData.count == 1) && (jsonData.return_code = "SUCCESS")) {
alert("One result");
}
else if(jsonData.return_code != "SUCCESS") {
alert("No Results");
}
}
});
},
Code snippet for the view it is being sent to:
BioGene.views.SearchListView = Ext.extend(Ext.Panel, {
layout: 'fit',
type: 'vbox',
align: 'center',
pack: 'center',
scroll: 'vertical',
initComponent: function () {
this.backButton = new Ext.Button({
text: 'Search',
ui: 'normal',
handler: this.onCloseTap,
scope: this
});
this.topToolbar = new Ext.Toolbar({
title: 'Genes',
items: [
//{ xtype: 'spacer' },
this.backButton
]
});
this.dockedItems = [this.topToolbar];
BioGene.views.SearchListView.superclass.initComponent.call(this);
},
onCloseTap: function () {
Ext.dispatch({
controller: BioGene.controllers.bioGeneController,
action: 'index',
slideDirection: 'right'
});
}
});