How would one refresh templates in ember (live)?
ember.js, javascript
Solution
note this works for simple templates, but not for ones that are rendered into outlets
Getting this going was rather tricky:
var js = "template.js";
var templateName = "template";
Ember.TEMPLATES["empty"] = Handlebars.compile("")
// script loaders are the simplest way of getting a callback
$LAB.script(js).wait(function(){
$.each(Ember.View.views,function(){
if(this.get('templateName')==templateName){
this.set('templateName','empty');
this.rerender();
this.set('templateName',templateName);
this.rerender();
}
});
})
Problem
During dev I would like to refresh my handlebar templates if they are saved live. I already have a websocket channel that notifies me when a file saves. At that point I can force a reload of the particular template by updating a hash on the `script` tag `src`. How can I notify all the Views that use this template that they need refreshing and force a refresh? (How can I find them? How do I trigger a refresh?)