How to bind to MDBSelect Open Event?


Topic: How to bind to MDBSelect "Open" Event?

Graham Meehan asked 5 years ago

What event is triggered when an MDBSelect is opened?

I'm looking to auto-focus on the search input inside of an MDBSelect when the dropdown is opened.

I've had no luck binding to the standard Bootstrap 'shown.bs.dropdown' event.


Sebastian Kaczmarek staff pro premium answered 5 years ago

You can capture the click event on the Material Select wrapper, for example like this:

 const $sel = $('#sel');

 $sel.materialSelect();
 $sel.parent().find('input').on('click', function(e) {

   const $search = $(this).find('.search-wrapper input');
   // do something with `$search`
 });

Graham Meehan commented 5 years ago

Perfect, thanks!

Small correction: '.search-wrapper input' needs to be ''.search-wrap input'.


Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Resolved

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