You just overwrite the view el property, which I think is not what you want. As you can see below, the make function does not attach the newly created element to the DOM, so it will not appear and the old element will not be removed from the page.
Possible way to fix it:
initialize: function(){ this.attributes = this.model.attributes; // why are you doing this anyway? :) var $oldEl = this.$el; // backbone 0.91 var newEl = this.make(this.tagName,this.attributes,''); $oldEl.after( newEl ); // the old element must be in the DOM, when doing this! $oldEl.remove(); this.setElement( newEl ); // proper setup }
Quotes from BackBone:
make: function(tagName, attributes, content) { var el = document.createElement(tagName); if (attributes) $(el).attr(attributes); if (content) $(el).html(content); return el; }, setElement: function(element, delegate) { this.$el = $(element); this.el = this.$el[0]; if (delegate !== false) this.delegateEvents(); return this; },
source share