"select2" 添加常量选项

"select2" Add constant option

我目前正在一个项目中使用 Select2,我想在我的 select 列表中添加一个选项,无论用户输入什么或搜索什么,它都会显示。这个想法是让 "Add new" 选项始终出现在列表中。 我不认为我的代码在这里是必需的(但如果需要我可以提供)因为我在这个特定主题中唯一缺乏的知识是如何保持选项始终显示。 我想到了使用 matcher 属性,但我不确定如何。

我已经成功地设置了一个新的匹配器,问题是我不确定如何创建一个新的匹配器并且仍然使用 select2 默认匹配器。 我缺少的其他东西是 select2 的完整版本。

function newMatcher(term, text){
    //The "ADD NEW" String is the text in the option I want to always show up.
    //The code after OR looks for the actual results for the user's search
    if ((text.toUpperCase().indexOf("ADD NEW") > -1)
       || (text.toUpperCase().indexOf(term.toUpperCase()) > -1)) {
         return true;
    }
}
$(document).ready(function() {
    $.fn.select2.amd.require(['select2/compat/matcher'], function (oldMatcher) {
        $('select').select2({
            matcher: oldMatcher(newMatcher)
        })
    })
});