3 ms·
I`ve been using Backbone, and one thing I forget all the time and bothers me is when you use Jquery plugins on elements that get re-rendered from templates (the
by swah 14y ago
I`ve been using Backbone, and one thing I forget all the time and bothers me is when you use Jquery plugins on elements that get re-rendered from templates (then you have to initialize the plugin on the element again, etc - for example, something like the Jquery UI Slider).
- elliottkember 14y agoTry breaking up your render method into smaller chunks, and only re-rendering content that needs replacing. You can even leave the el if it exists already, and just update text or form fields.
- swah 14y agoI do that in some places, but its much harder to this.$el.find and replace elements than just re-running the template.
- some1else 14y agoThe render method is the right place to hook things up with the DOM. Although I trust the garbage collection is up to par when it comes to forgotten DOM elements, I've recently started implementing destroy methods on views that deal with more complex jQuery plugins. Some plug-ins implement destroy methods themselves, but in some places I just unbind the few events manually.