Reputation: 81
Is there any way in Ember to update the Handlebars template content and re-render the dependent views dynamically?
I tried by using Ember.TEMPLATES
and Ember.Handlebars.compile
method, but it didn't worked and the JSFiddle is available here, so any suggestions?
Upvotes: 3
Views: 466
Reputation: 3745
Capture anything you want the user to manipulate in the template as a property of the view/controller and create a binding for it either as computed property or attach an observer to it. This way you can create a view dynamically and append it anywhere you want in your document.
Upvotes: 0
Reputation: 7458
I don't know why you're attempting to do this, but if it's just for testing sake, here is a working fiddle http://jsfiddle.net/VTP4n/2/.
Ember caches the template inside the view as a computed property, so I'm overriding it and calling rerender
on the view. I wouldn't even consider using this in production though.
Up until recently, it was as easy as overriding the template and then calling view.notifyPropertyChange('template')
, but with the new container stuff, it's a lot more complex to do it cleanly.
Upvotes: 2