Problem when using Select

Asked

Viewed 5,408 times

4

I’m trying to use the form select of this site here:
http://materializecss.com/forms.html

But when I put on my site the only thing that appears is this:

"Materialize Multiple Select"

Someone knows how to fix this?

The code is this:

<div class="input-field col s12">
    <select multiple>
      <option value="" disabled selected>Choose your option</option>
      <option value="1">Option 1</option>
      <option value="2">Option 2</option>
      <option value="3">Option 3</option>
    </select>
    <label>Materialize Multiple Select</label>
  </div>
  • You initialized the plugin using the: $('select').not('.disabled').material_select(); ?

  • Yeah, it didn’t work either =/

  • Did you reference the jQuery.js file before the materialize.js file? You put them at the bottom of the page before the </body> ?

  • yes I put before the /body

1 answer

5


It may be missing some file. Add how you referenced them in your html. Remembering that you need to "start" the material_select(), in this way:

$(document).ready(function() {
    $('select').material_select();
});

A functional example of select is below:

<script type="text/javascript" src="//code.jquery.com/jquery-2.1.4.js"></script><style type="text/css"></style>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/css/materialize.min.css">    
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/js/materialize.min.js"></script>
    
<script type="text/javascript">//<![CDATA[
window.onload=function(){
$(document).ready(function() {
    $('select').material_select();
});
}//]]> 

</script>
<div class="input-field col s12">
    <select multiple>
      <option value="" disabled selected>Choose your option</option>
      <option value="1">Option 1</option>
      <option value="2">Option 2</option>
      <option value="3">Option 3</option>
    </select>
    <label>Materialize Multiple Select</label>
  </div>

The same can be seen in Jsfiddle.

Related: Materialize CSS - Select Doesn’t Seem to Render

  • Opa now worked, I deleted my references and used yours and it worked, it may be that my file was with some problem, vlw :D

  • @Ingi These are the site’s own references. If you want to place site, you can download them.

  • Then my was local and was not giving, will the file was corrupted ?

  • @Ingi If you downloaded from the site, hardly. It is more likely that you are referencing it wrong. To be sure, just open the developer options (F12) and look if you’re not getting any errors in the console tab.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.