jquery select2 plugin how to get only the result 'myString%'

前端 未结 1 1971
执念已碎
执念已碎 2021-01-20 05:16

i\'m using the jquery-select2 plugin but i\'m wondering how can i get only results that begins with the typed keyword ( like \'myString%\')

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-20 05:58

    The documentation actually provides an example for that:

    $("select").select2({
        matcher: function(term, text) {
            return text.toUpperCase().indexOf(term.toUpperCase())==0;
        }
    });
    

    The above matcher is case-insensitive, for case-sensitive remove both .toUpperCase() calls.

    0 讨论(0)
提交回复
热议问题