Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change placeholder of selectize.js dropdown?

I want to change placeholder of a dropdown created by selectize.js when the parent dropdown changes its selection to load the options of the dropdown whose placeholder to be changed. There is no method to do this in documentation.

like image 747
freezer Avatar asked Oct 02 '13 17:10

freezer


2 Answers

You can specify a placeholder key as part of the options object when initialising. I couldn't find the option in the documentation and only found it digging through the code.

//init selectize
$(function() {
  $('select').selectize({
    placeholder: 'Click here to select ...',
  });
});
like image 106
johnz0r Avatar answered Sep 26 '22 10:09

johnz0r


You need two things:

  • add empty <option></option> as first option tag in the select.
  • add placeholder key to selectize call
like image 27
mikdiet Avatar answered Sep 23 '22 10:09

mikdiet