I'm very new to JS and I'm retrying EmberJS due to the impending 2.0 but especially because of EMBER CLI which I really like the structure.
Anyways, I'm building a basic app and what I'm currently looking to do is make a JSON call to reddit to grab the subscriber number and apply that number to a models subscriber number attribute. I'll also be cycling through an array of models too.
So for my instance, I've got models of lets say sports teams. Each team as a subreddit and when someone clicks the league they want, I'll be displaying all of the teams in that league.
I've got the the JSON working from a pure JS aspect, and I've got the Ember app working w/o any JSON. So I'm just trying to figure out how to connect the two while also realizing I will probably need to do some tear down to properly connect the two.
So my question is, how do I go about selecting a single piece of data from Reddit API to a single model attribute?
Here is the JS I'm using currently to pull the subscriber number.
$.each( teamList, function( key, val ) {
$.getJSON(
"http://ift.tt/1xFE9lt"+val+"/about",
function foo(data)
{
$("#team").append(val + " : ");
$("#team").append(data.data.subscribers + '<br>');
}
);
});
My current ember model setup is normal, but I am using fixtures since all data is static other than this model attribute.
Aucun commentaire:
Enregistrer un commentaire