PDA

View Full Version : Template won't show children for Yahoo weath\



BostonMerlin
9 Sep 2011, 2:47 PM
I'm trying to perform a simple loop to show weather information from yahoo. The json includes a collection of weather forecast objects that will not show. Looking at the object in Chrome shows two "forecasts" objects in the array, so it appears the data is being pulled in correctly. Temperature below shows fine, so it's getting the root no problem. Thoughts?

The data

{
"weather":
[{
"id":1,"Code":"30","Temperature":"79","Text":"Partly Cloudy",
"forecasts":[
{"id":1,"Code":"33","Low":"61","High":"79","Day":"Fri"},
{"id":2,"Code":"34","Low":"54","High":"73","Day":"Sat"}],
"Location":"Waltham, MA"}],"id":1,"PageTitle":""
}




The template

itemTpl: new Ext.Template(
"<tpl for='.'>",
"<span>{Temperature}</span>",
"<tpl for='forecasts'>",
"<span> {Day} {Low} {High}</span>",
"</tpl>",
"</tpl>"
),


The Models

Ext.regModel('App.Area.Home.Widgets.Models.Weather', {
fields: ['id','Code', 'Link', 'Temperature', 'Text', 'Location'],
associations: [{type: 'hasMany', model: 'App.Area.Home.Widgets.Models.Forecasts', name: 'forecasts'}],
});
Ext.regModel('App.Area.Home.Widgets.Models.Forecasts', {
fields: ['id','Code', 'Low', 'High', 'Day'],
associations: [{type: 'belongsTo', model: 'App.Area.Home.Widgets.Models.Weather'}],
});
Ext.regStore({
storeId: 'App.Area.Home.Widgets.Store.Weather',
model: 'App.Area.Home.Widgets.Models.Weather',
proxy: { type: 'ajax', url: 'Data.txt',
reader: {type:'json', root:'weather'},
}
});


Pulling my hair out on this one... it's not rocket science is it? :)