Last active
December 16, 2015 22:29
-
-
Save bradleypriest/5507321 to your computer and use it in GitHub Desktop.
Ember 1.0-rc3 Handlebars reloading. Slightly modified from https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/components/development.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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