MaterialSelect Mutation Observer Use?


Topic: MaterialSelect Mutation Observer Use?

yoni45 asked 5 years ago

The MDB code for MaterialSelect has references to create mutation change observers which seem to be interfering with something I'm trying to do (also seems to interfere with an undocumented feature you guys included -- destroying and reinitializing a MaterialSelect, for some reason, breaks any data-icons that should be created).

I've commented out all code relating to mutation observers in an override file and it fixed the issue without any apparent ill-effects.

Just in case I didn't notice something though, any chance you guys could clarify what exactly the mutation change observers are being used for (that I might have broken)?

Thanks!


Mikołaj Smoleński staff commented 5 years ago

Mutation Observers were added to the native select which is overwritten by our Material one. While changing anything in native version (for example: adding a new option) the Material one has to reload with the new data set. It should be turned on mainly if you're working with the dynamic data. If it's not working correct in your case you can leave it commented.

Best regards


yoni45 commented 5 years ago

Just to follow-up -- is it possible to dynamically add entries to a MaterialSelect without having to destroy/reload the entire set? Documentation currently says you have to simply destroy and reload it (which presumably has more overhead)?


Mikołaj Smoleński staff commented 5 years ago

In the latest versions of MDB there is no need to destroy and reload select due to the mutation observers. If you add/change/delete any option in the native select it should re-render automatically.

Best regards


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Open

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.8.5
  • Device: Desktop
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No