Reputation: 82
So, is there a generally-accepted way to do this? Attaching to didRenderElement in a view seems to work, unless you need data from the model.
Likewise, you can override setupcontroller to run something once a model is loaded, but who knows if your elements are rendered yet?
Should I be using "on"? If so, on what? Where?
How about if I want to wait until the model is loaded, elements are rendered, AND, say, images are loaded?
Upvotes: 0
Views: 189
Reputation: 23322
The thing here is that didInsertElement
only notifies you when the template has being rendered into the DOM, images loaded or not. Normally the rendering will wait until your model has being resolved to render the template, but in case of images this is somewhat different, because I guess your model only contains the url's to the images and not the raw data.
Should I be using "on"? If so, on what? Where?
To be notified when all your images has being loaded you could use a plugin like: http://desandro.github.io/imagesloaded/ and attach an observer to the plugin event to be notified, ember does not know when your images are being completely loaded it cares only for your model being resolved, then it will render your template.
Hope this helps.
Upvotes: 2