Closed ghost closed 11 years ago
The solution I settled on was to watch the container that holds the various dashboards and apply gridster to any new elements:
$('#dashboards').on("DOMNodeInserted", function (event) {
if (event.target.parentNode.id == 'dashboards') {
$(event.target).children("ul.dashboard").gridster(gridsterSettings);
};
});
It appears DOM mutation events have been deprecated (but this appears to work fine in the browser's we are supporting.)
We're building a paginated dashboard application wherein widgets can be dragged and reordered -- works great!
However, the user can create additional dashboards on the fly without reloading the page. New dashboard containers (Gridster grids...) are added to the DOM when the user clicks a button. The problem is Gridster hasn't been initialized on the newly added grid, so neither preloading the grid with widgets or dynamically adding a widget works, i.e., "Uncaught TypeError: Cannot call method 'add_widget' of undefined"
What is the best method of applying gridster to a dynamically added element? I haven't had any luck playing with variations of this:
Thank you in advance for any help.