I need to run a script layout as soon as my views are inserted into the DOM. So that...
$(".widgets").append(widgets.render().el) $(".widgets .dashboard").isotope
The problem is that I have to insert new widgets in several different kinds and re-call this script several different places, which is not DRY. I am wondering how I can define isotope in a View class.
Would it be nice to define an event listener to add to ".widgets" and run the script? Is there a built-in way to create views that are reasonable when they are added to the DOM?
(In this case, it would also be useful to define a callback when the View is removed from the DOM.)
source share