質問

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.

役に立ちましたか?

解決

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top