EmberJs - How do I update the content of a Handlebars template after loading a view?

Is there a way in Ember to update the content of the Handlebars template and dynamically render the dependent views?

I tried using method Ember.TEMPLATES

and Ember.Handlebars.compile

, but it didn't work and JSFiddle is available here , so any suggestion?

+3


source to share


2 answers


I don't know why you are trying this, but if it's just for testing, here is a working fiddle http://jsfiddle.net/VTP4n/2/ .

Ember caches the template inside the view as a computed property, so I override it and call it rerender

in the view. I wouldn't even consider using this in production.



Until recently, this was as easy as redefining a template and then calling view.notifyPropertyChange('template')

, but with the new content of the container, it was much more difficult to do it cleanly.

+2


source


Grab whatever you want the user to manipulate in the template as a view / controller property and create a binding for it either as a computed property or attach an observer to it. This way you can dynamically create a view and add it anywhere in the document.



0


source







All Articles