Add values to a chosen multiselect

后端 未结 3 1137
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-07 06:16

I am wondering whether it\'s possible to add new values on the fly to a chosen.js multiselect (similar to how tagging works).

I\'ve seen in another SO post a user s

3条回答
  •  梦谈多话
    2021-01-07 07:08

    The solution is here

    $('select').chosen({plugins: ['option-adding']});
    

    or

    $(function() {
      $(".chzn-select").chosen({
        create_option: true,
        // persistent_create_option decides if you can add any term, even if part
        // of the term is also found, or only unique, not overlapping terms
        persistent_create_option: true,
        // with the skip_no_results option you can disable the 'No results match..' 
        // message, which is somewhat redundant when option adding is enabled
        skip_no_results: true
      });
    });
    

提交回复
热议问题