I just upgraded my Backbone to 0.9.2 and when I do a view.remove() like I did with the older version it no longer is working for me.
I have a popup.js view called processingView that just has some jquery code wrapped in an view extend. I assign this to a variable called processing.
this.processing = new processingView();
When I fire an event to remove the processing object from the Dom by saying. this.processing.remove() it no longer gets removed. If I revert back to the older version of Backbone it works.
Anyone got any ideas why this would be.
My code is a huge amount of source files so its hard to paste all this in here. But as far as what I’m trying to do it should be straight forward remove a view object from the dom.
ANSWERED MY OWN QUESTION
Ok I was not using setElement when I was manually setting View.el
If you’ve ever manually set this.el in a Backbone View to be a particular DOM element, you’ll want to use setElement instead.
Its still not clear what the difference between view.el and view.$el. Maybe someone can straighten that out for me.
view.$elis equivalent to$( view.el ). It’s a convenience so that you don’t have to incur the hassle and additional overhead of repeatedly calling the jQuery constructor. You may want to structure your code (if possible) so that you don’t need to manually seteland callsetElement. You can see my answer to another question for an example.