jQuery Chosen plugin without search field

前端 未结 12 904
时光说笑
时光说笑 2021-02-05 02:45

Not sure if this has been covered somewhere, but I couldn\'t find it in the documentation, and was wondering if it\'d be possible to not include the search input box with the jQ

12条回答
  •  长情又很酷
    2021-02-05 03:09

    Newer versions of jquery chosen gives you option to disable search input with in dropdown.

    $(".chzn-select").chosen({
       disable_search: true
    });
    

    Older versions do not support this option. Some how if you are strictly not allowed to use newer version than you can use

    $(".chzn-select").chosen({
       disable_search_threshold: 5
    });
    

    it will hide the search box if results are less than 5, best to use with gender type dropdowns. There is another way to fix this and that is;

    $(".chzn-select").chosen();
    $(".chzn-select").hide();
    

    Call hide immediately after initialization, don't know why this tricks works but it is doing what you want!

    I suggest you to use the latest version so you have access to latest options.

    Hope it works for you!

提交回复
热议问题