【问题标题】:Select2 acts very different with Uncaught query function not defined for Select2 <select2-id>Select2 的行为与未为 Select2 <select2-id> 定义的未捕获查询函数非常不同
【发布时间】:2013-07-08 09:29:48
【问题描述】:

我像下面这样为 select2 加载值。

声明类型

var  AdjustmentType = Backbone.Model.extend({
            url : Hexgen.getContextPath("/referencedata/adjustmenttype")
    });

为类型创建实例

var adjustmentTypes = new AdjustmentType();

将值加载到 select2 框

adjustmentTypes.fetch({
                    success : function() {
                        for(var count in adjustmentTypes.attributes) {
                            $("#adjustment-type").append("<option>" + adjustmentTypes.attributes[count] + "</option>");
                        }
                    }
                });  
                $("#adjustment-type").select2({
                     placeholder: "Select Adjustment Type",
                     allowClear: true
                 });

我的 HTML 代码

<div class="span4">
        <div>ADJUSTMENT TYPE</div>
        <select id="adjustment-type" tabindex="5" style="width:200px;">
            <option value=""></option>
        </select>
    </div>

当我第一次加载它时,它没有给出任何异常,但如果我 Refreshnavigate to different URL 我得到以下异常:

Uncaught query function not defined for Select2 adjustment-type

【问题讨论】:

    标签: html backbone.js marionette jquery-select2 bootstrapping


    【解决方案1】:

    “查询”是指用来检查您的搜索词的列表。您需要确保您的 data 属性是正确的对象数组(即您的选项元素)。

    【讨论】:

      猜你喜欢
      • 2016-02-27
      • 2013-01-07
      • 2016-01-21
      • 2019-11-14
      • 1970-01-01
      • 2021-06-22
      • 1970-01-01
      • 2017-03-06
      • 2022-08-08
      相关资源
      最近更新 更多