Skip to content

Instantly share code, notes, and snippets.

@bradleypriest
Last active December 16, 2015 22:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradleypriest/5507321 to your computer and use it in GitHub Desktop.
Save bradleypriest/5507321 to your computer and use it in GitHub Desktop.
// https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/components/development.js
// Updated for Ember 1.0-rc3
Ember.reloadTemplate = function(templateName) {
Ember.TEMPLATES.empty = Handlebars.compile("<div></div>");
$.getScript("/assets/templates/" + templateName, function(data, textStatus, jqXhr) {
delete Ember.Container.defaultContainer._container.cache.dict["template:" + templateName]
$.each(Ember.View.views, function() {
var _this = this;
if (this.get('templateName') === templateName) {
this.set('templateName', 'empty');
this.rerender();
return Em.run.next(function() {
_this.set('templateName', templateName);
return _this.rerender();
});
}
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment