-
7 Feb 2012 3:54 AM #1
Unanswered: Refreshing and displaying JSON in tab panels.
Unanswered: Refreshing and displaying JSON in tab panels.
Hi, I'm new to sencha and need a bit of help. Below is code for a 3 page tab panel. The second tab needs to display weather results from a JSON request. It also needs to be refreshed/reloaded every time you click on the weather button.
I'm getting the data but having trouble to display it, I also need help with the refreshed/reloaded problem.
Thank you in advance.
Code:Ext.setup({ onReady: function () { var favoritesTab = { title: 'Favorites', iconCls: 'favorites', html: 'Favorites' }; var settingsTab = { title: 'Settings', iconCls: 'settings', html: 'Settings' }; var weatherDisplay = new Ext.Component([ '<div class="demo-weather">', '<tpl for=".">', '<div class="day">', '<div class="date">{date}</div>', '<tpl for="weatherIconUrl"><img src="{value}"/></tpl>', '<span class="temp">{tempMaxF}°<span class="temp_low">{tempMinF}°</span></span>', '</div>', '</tpl>', '</div>' ]); var weatherTab = { id: 'weatherTab', title: 'Weather', iconCls: 'team', layout: 'card', items: [{ html: 'Please Wait...' }, weatherDisplay], listeners: { activate: function () { // this == Ext.getCmp('peopleTab') // this.getLayout().setActiveItem(0); Ext.util.JSONP.request({ url: 'http://free.worldweatheronline.com/feed/weather.ashx', callbackKey: 'callback', params: { key: '23f6a0ab24185952101705', q: '94301', // Palo Alto format: 'json', num_of_days: 2 }, scope: this, callback: function (data) { weatherDisplay.update(data.results); this.getLayout().setActiveItem(1); } }); } } }; new Ext.TabPanel({ fullscreen: true, tabBar: { dock: 'bottom', layout: { pack: 'center'} }, animation: { type: 'cube' }, items: [favoritesTab, weatherTab, settingsTab] }); } });Last edited by mitchellsimoens; 7 Feb 2012 at 6:35 AM. Reason: added [CODE] tags
-
7 Feb 2012 6:35 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,085
- Vote Rating
- 453
- Answers
- 3153
Is this a Sencha Touch question?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
7 Feb 2012 7:09 AM #3
-
7 Feb 2012 7:14 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,085
- Vote Rating
- 453
- Answers
- 3153
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
7 Feb 2012 7:17 AM #5
Sencha Touch 2 please, sorry very new at this. Thanks


Reply With Quote