-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Destroy/Remove selects #819
Comments
On the latest version, we rewrote material_select to destroy old instances on reinitialization |
Has this been implemented into master? Because I have just downloaded the latest materialize, and each new |
I saw the code, but I'm not reinitializing the material_select. I'm removing it entirely from the Document. It's not being recreated. It's going away. If it comes back, it will be an entirely new |
In my test, the old select is removed. |
This is probably no different than the issue I was discussing in #452 . As I said there I replace the select element with a new one in the following manner:
Each time the
|
What is the point of |
To create a new select element to replace the old instead of trying to edit the old one. There are a few reasons why having something like that reduces significantly the amount of js code I had to write. |
makes sense. It's simply to create a new select than compare the options and change/add/remove what's necessary. |
I cannot seem to get material_select() to overwrite the existing control. It actually does nothing if run again. |
@viniciusmelquiades @Dogfalo Sorry to be a bit of a nuisance on this one. But i've probably put about 12 hours into the various select problems. Could you explain a little more how you fixed the select issue.... I am using the meteor build on atmosphere. There are two issues that i am facing referenced by other issues logged
I would also ask a question regarding re-building all these components. Would a better approach have not to use tried and tested components e.g select2 and simply skin it for materialize css. This would seem more practical than trying to rebuild a whole world of functionality that already exists.... |
@ganySA I don't really understand your problem. This issue is regarding removing junk left by the select. Calling .material_select() reloaded the select with the new options, last time I checked, and the pull request allows us to call .material_select('destroy') to get rid of the junk and return the select to it's uninitialized state. Although you have a good point about select2, that's something to be discussed in another issue. |
@viniciusmelquiades the problem was fixed on meteor in the latest version. The second problem is still there and only works with mouse scroller but there is an open issue around that. #901 |
@ganySA Then we should use that issue to discuss that problem. This one doesn't have anything to do with the scroll problem. |
+1 for select2 |
2 similar comments
+1 for select2 |
+1 for select2 |
I was still facing issues with the junk left on re-initialize so I've created a pull request to fix that. See if it helps you. |
I'm done with this junk framework... |
Please keep in mind that this framework is still in beta. |
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 theul
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 likeAnother way would be with an jQuery event, kind of like angularjs does:
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.
The text was updated successfully, but these errors were encountered: