I just want a confirmation about what I’m doing in my app.
I created some jquery plugins which add some elements and events in the DOM of my page.
For example, I init the plugin in a DOM element of my page:
$("#myplugin_container").myplugin('init', {'data':mydata});
What I want to know : if I remove the container with remove function
$("#myplugin_container").remove();
, will I have memory leaks on the plugin or will the jquery object be removed correctly ?
I hope my explanations are clear…
Thanks !
jQuery will remove all event handlers and other data associated with the element when you use .remove(), so there shouldn’t be any memory leaks.
From jQuery documentation of remove():