Skip to content
This repository has been archived by the owner on Mar 20, 2021. It is now read-only.

Commit

Permalink
Remove elements before innerHTML is set for IE
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Eastridge committed Dec 21, 2012
1 parent c4d5692 commit 4622c4e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/helpers/element.js
Expand Up @@ -13,9 +13,11 @@ Handlebars.registerHelper('element', function(element, options) {
// IE will lose a reference to the elements if view.el.innerHTML = '';
// If they are removed one by one the references are not lost
Thorax.View.on('before:append', function() {
_.each(this._elementsByCid, function(element, cid) {
$(element).remove();
});
if (this._renderCount > 0) {
_.each(this._elementsByCid, function(element, cid) {
$(element).remove();
});
}
});

Thorax.View.on('append', function(scope, callback) {
Expand Down
10 changes: 10 additions & 0 deletions src/helpers/view.js
Expand Up @@ -23,6 +23,16 @@ Handlebars.registerHelper('view', function(view, options) {
return new Handlebars.SafeString(Thorax.Util.tag(htmlAttributes, undefined, expandTokens ? this : null));
});

// IE will lose a reference to the elements if view.el.innerHTML = '';
// If they are removed one by one the references are not lost
Thorax.View.on('before:append', function() {
if (this._renderCount > 0) {
_.each(this.children, function(child, cid) {
child.$el.remove();
});
}
});

Thorax.View.on('append', function(scope, callback) {
(scope || this.$el).find('[' + viewPlaceholderAttributeName + ']').forEach(function(el) {
var placeholderId = el.getAttribute(viewPlaceholderAttributeName),
Expand Down

0 comments on commit 4622c4e

Please sign in to comment.