admin管理员组文章数量:1317898
I have developed a large "single page application" using jQuery and jQuery UI. As I load various sections in the app it creates jQuery UI widgets like dialogs or date pickers. They tend to hang around and cause some issues when I reload certain sections. I would like the ability to call a function that destroys all jQuery UI widgets that have been loaded and remove them from the DOM. Any solution to catch all of them? Thanks!
I have developed a large "single page application" using jQuery and jQuery UI. As I load various sections in the app it creates jQuery UI widgets like dialogs or date pickers. They tend to hang around and cause some issues when I reload certain sections. I would like the ability to call a function that destroys all jQuery UI widgets that have been loaded and remove them from the DOM. Any solution to catch all of them? Thanks!
Share Improve this question asked Oct 25, 2012 at 5:33 JeremyJeremy 1,0734 gold badges18 silver badges34 bronze badges2 Answers
Reset to default 7In theory, it's easy enough to locate and destroy all widgets of a specific type on a page:
$(":ui-draggable").draggable("destroy");
So, it isn't unthinkable to create a loop around an array of widget types you know you're using, and delete every kind of widget on the list.
Use remove()
or detach()
to clear the contents of your jquery UI widgets and here is the difference
remove() removes the matched elements from the DOM pletely.
detach() is like remove(), but keeps the stored data and events associated with the matched elements.
本文标签: javascriptHow do I destroy all jQuery UI widgetsStack Overflow
版权声明:本文标题:javascript - How do I destroy all jQuery UI widgets? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742033770a2416944.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论