Pre-populate Ember DS.Store via ajax

Reading the Ember guide about the data store it's not clear how you pre-populate the store with your data. I see you can set up the RESTadapter with the host name, and the 'store.find' method will trigger a 'get' request if the data is not cached, but how can I initialize a DS.Store with JSON data via ajax before ever doing a find? Ember guide model HTTP

The context for this is, a single page app that on page load gets a blob of json, which is used to model out the rest of the site. The end result gives the illusion that the site contains multiple pages.

Answers


Sounds like you want this.store.pushPayload(..)

http://emberjs.com/api/data/classes/DS.Store.html#method_pushPayload

Note that you only have access to the store inside Routes and Controllers. Consider putting this inside the activate hook of App.ApplicationRoute

http://emberjs.com/guides/routing/defining-your-routes/#toc_initial-routes http://emberjs.com/api/classes/Ember.Route.html#method_activate


Need Your Help

Installing packages with pip with multiple python installs

python windows pip anaconda

I have been using Anaconda python on Windows 7, but a package I need isn't supported by Anaconda python, so I installed CPython from python.org. I'd like to install the package to CPython, but pip ...

Loading jQuery with Dojo AMD loader Issue

javascript jquery dojo

I am trying to load jQuery using Dojo AMD. which is working fine when I use Jquery CDN path