Skip to content

Instantly share code, notes, and snippets.

@csprocket777
Last active December 19, 2015 00:28
Show Gist options
  • Save csprocket777/5868494 to your computer and use it in GitHub Desktop.
Save csprocket777/5868494 to your computer and use it in GitHub Desktop.
This gist shows how to load in a json file into a single page EmberJS app as a "preferences" file and have it be persistent. I arrived on this code by trial and error during my learning of emberJS so it's probably got issues and could be more elegant. Thought it helpful to document it somewhere.
Env.IndexRoute = Ember.Route.extend({
model: function(){
return $.ajax({
url: "data/player.json",
dataType: "jsonp",
jsonpCallback:'playerData',
crossDomain: true
});
},
setupController: function( controller, model )
{
controller.set('model', model);
}
});
@csprocket777
Copy link
Author

Ok. so moments after posting this I realized that my json file was more complex than I needed it to be. I restructured my json file to be simpler and was able to remove the "player[0]" portion of the previous code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment