How to change placeholder of selectize.js dropdown?

后端 未结 10 1411
盖世英雄少女心
盖世英雄少女心 2021-02-14 12:30

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 cha

10条回答
  •  死守一世寂寞
    2021-02-14 13:33

    I had a similar issue - what was frustrating is I would do something like this:

    $("selectize-input input[placeholder]").attr('placeholder','Hello World!');
    

    Then only after changing the focus it would render my new placeholder text. It turns out that for whatever reason (probably a good one) selectize applies a width to this input.

    Final solution:

    $(".selectize-input input[placeholder]").attr('placeholder','Hello World!');
    $(".selectize-input input[placeholder]").attr("style", "width: 100%;");
    

提交回复
热议问题