select2 v4 dataAdapter.query 未触发

select2 v4 dataAdapter.query not firing

我有一个输入,我希望为自定义查询绑定一个数据适配器,如 https://select2.org/upgrading/migrating-from-35#removed-the-requirement-of-initselection

中所述
<input name="pickup_point">

我的脚本:

Application.prototype.init = function() {
    this.alloc('$pickupLocations',this.$el.find('[name="pickup_point"]'));
    var that = this;
    $.fn.select2.amd.require([
        'select2/data/array',
        'select2/utils'
        ], function (ArrayData, Utils) {
            var CustomData = function($element, options) {
                CustomData.__super__.constructor.call(this, $element, options);
            };Utils.Extend(CustomData, ArrayData);
            CustomData.prototype.query = function (params, callback) {
                var data = {
                    results: []
                }; 
                console.log("xxx");
                for (var i = 1; i < 5; i++) {
                    var s = "";

                    for (var j = 0; j < i; j++) {
                        s = s + params.term;
                    }

                    data.results.push({
                        id: params.term + i,
                        text: s
                    });
                }

                callback(data);
            };

            that.$pickupLocations.select2({
                minimumInputLength: 2,
                language: translations[that.options.lang], 
                tags: [],
                dataAdapter: CustomData

            });

        });

}

但是当我在 select2 搜索框中键入时,我正在记录以进行测试的 xxx 没有出现在我的控制台中。

我该如何解决这个问题?

我在 https://github.com/select2/select2/issues/4153#issuecomment-182258515

问题是我试图在输入字段上初始化 select2。

通过将类型更改为 select,一切正常。

<select name="pickup_point">
</select>