material_select() callback does not support event handling


Topic: material_select() callback does not support event handling

mirnesc92 pro asked 7 years ago

How can I access event from material_select()'s callback?

$('.mdb-select').material_select(function() {
console.log('how can i tie this to specific select triggered');
});

I have an array of select's and can't figure out which one was clicked.

 

Is there a way to manually build element produced by material_select() with full functianality ?

<div class="select-wrapper mdb-select"> <span class="caret"></span><input type="text" readonly="readonly" data-activates="select-options-ce634e39-553a-4033-b8f1-cf0d9afbe03a" value="Open" class="select-dropdown"> <ul id="select-options-ce634e39-553a-403c-b8f1-cf0d9afbe03a" class="dropdown-content select-dropdown "> <li><span class="filtrable">Open</span></li> <li><span class="filtrable">Closed</span></li> <li><span class="filtrable">Message</span></li> </ul> </div>

 


mirnesc92 pro commented 7 years ago

material_select() should not be creating new elements but instead transforming existing [select] and [option] elements, the current process makes complex customization impossible. I am trying to bind attributes from [select] element to VueJS but it is useless because the [select] and [option] elements are ignored and replaced with [ul][li] elements generated by material_select(). It can work for simple cases using a lot of hack-ish code but is not for complex use cases were [select] elements are dynamically generated after an AJAX call for example.

Jakub Strebeyko staff answered 7 years ago

Hi there, Thanks for taking time and reaching out, the input is appreciated. Unfortunately not - to have material_select working means feeding it <option> elements only to have them replaced by list items. The suggestion stands, naturally, and has been added to the idea board we use in the development process - which is the best we can do for now. If you ever get a chance, try out MDB Vue, where the select is rebuild from ground up and works the way you mention. With Sincere Regards, Kuba
Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: Yes
  • Provided link: No