question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Destroy/Remove selects

See original GitHub issue

While developing a Single page application, I noticed there is no way to remove, or destroy a material select. I can remove the select tag, but the ul created for styling is not removed, and I couldn’t find any way to remove it with the jQuery library provided. This can become a problem as the user navigates through the application and the DOM elements don’t get removed, resulting in a memory leak.

The best way to do it is adding a overload to $.fn.material_select(), passing an argument to destroy the select. So it would be something like

$('#myselect').material_select('destroy');

Another way would be with an jQuery event, kind of like angularjs does:

$('#myselect').trigger('$destroy'); //angularjs uses the $destroy event before removing directives.

After a quick look at your code, I think I can implement either for you. Just tell me what of the options you want and I’ll fork it and implement it.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:3
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
apudiucommented, Nov 7, 2017

I’m done with this junk framework…

0reactions
Whipcommented, Nov 8, 2017

Please keep in mind that this framework is still in beta.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap select destroy removes the original select from DOM
Found the solution, I edit the plugin function destroy where instead of removing the original element, I show it back:
Read more >
Methods | Select2 - The jQuery replacement for select boxes
Destroying the Select2 control. The destroy method will remove the Select2 widget from the target element. It will revert back to a standard...
Read more >
MaterialSelect Destroy - Material Design for Bootstrap
I've noticed that mdb pro has a bug in initialization or wrong documentation. Due to the fact that after initialization of select (calling...
Read more >
destroy - API Reference - Kendo UI AutoComplete
data attributes to avoid memory leaks. Calls destroy method of any child Kendo widgets. Important: This method does not remove the widget element...
Read more >
Flickity · API
jQuery $carousel.flickity( 'select', index, isWrapped, isInstant ) ... Remove Flickity functionality completely. destroy will return the element back to its ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found