materialSelect is not a function - even in basic snippet


Topic: materialSelect is not a function - even in basic snippet

Kneidels pro asked 3 years ago

Am trying some basic troubleshooting - i cant even get the most basic material select to work... error i get is: materialSelect is not a function

what am i missing??

Thanks

https://mdbootstrap.com/snippets/jquery/moshe/3276129#js-tab-view

$('select[name=drop]').materialSelect();

  <select name="drop" id="drop">
  <option value="">Select...</option>
  <option value="1">1</option>
  <option value="2">2</option>
    <option value="3">3</option>
  </select>

UPDATED:

when i use this code, in the JS window, the select field IS generated, but the default does not disappear!

$(document).ready(function() {
  $('.drop').materialSelect();
});

Marcin Luczak staff answered 3 years ago

Hi,

This is because according to the material select documentation material select element should have mdb-select md-form class. Following code will work properly:

<select name="drop" id="drop" class="drop mdb-select md-form">
  <option value="">Select...</option>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
</select>

Keep coding, Marcin


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: Pro
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: MDB4 4.19.1
  • Device: PC
  • Browser: Firefox
  • OS: WIN10
  • Provided sample code: No
  • Provided link: Yes