jQWidgets Forums
jQuery UI Widgets › Forums › General Discussions › jQWidget does not clean up dom on unload
This topic contains 7 replies, has 3 voices, and was last updated by gvv 12 years, 7 months ago.
-
Author
-
I am currently using jqWindow, jqTab and jqExpander Widget. They are great, but it seems that if one manually closes one of this widgets it is not possible to restore them unless the page is completely reloaded. Does jQWidget clean up correctly the DOM once the functionality is closed ? Actually, I need to do it manually which is quite annoying.
Thank you for you help.
Hi stefan.r.meier,
Our widgets are jQuery-based client-side widgets and are built once the DOM is loaded. When you close the web page and reopen it, widgets will be initialized again as the DOM will be loaded again.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
Thank you for your reply.
My application is a Single Page Application and the DOM is never completely reloaded. So if one closes a widget, it should be possible to reopen it again. That’s the reason of my question concerning unloading.
Best regards,
StefanHi Stefan,
What do you mean by closing a widget? Clicking the jqxWindow’s close button or something else? If that’s what you mean, to open the window again, use its ‘open’ method. If you don’t reload your page, make sure that you initialize the widgets just once.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
Thank you for your reply.
By closing a widget I mean clicking on the close button. I will try to reopen it with the open method as you suggest. Is there no possibility to remove completely a widget and to restore it when it is needed again. If all widgets are kept on the page, the DOM becomes too overloaded.
Best regards,
StefanHi Stefan,
To remove a widget from the DOM, use the jQuery’s remove method. To add a widget again, create a DIV tag dynamically, append it to the document’s body by using the jQuery’s append method and initialize the widget by selecting the DIV tag by ID and calling the widget’s constructor.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
I will try this again.
Best regards,
Stefantry
$(“#selector”).removeData(“jqxWidget”);
-
AuthorPosts
You must be logged in to reply to this topic.