选择二的行为非常不同势与选择二&LT没有定义未捕获的查询功能;选择2-ID> [英] Select2 acts very diffrent with Uncaught query function not defined for Select2 <select2-id>

查看:151
本文介绍了选择二的行为非常不同势与选择二&LT没有定义未捕获的查询功能;选择2-ID>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我加载值SELECT2像下面的方法。

I load values for select2 like the following way.

声明类型

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

的类型创建实例

var adjustmentTypes = new AdjustmentType();

加载值来选择2盒

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 code

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

当我加载此为第一它不给予任何异常,但如果我刷新导航到不同的URL 我得到了以下异常:

when i load this for the first it is not giving any exception but if i Refresh or navigate to different URL i get the following exception :

Uncaught query function not defined for Select2 adjustment-type

所以也不知道了么可能是原因,

so don't know the what could be the cause,

请问一些身体帮我找的是什么问题?

Would some body help me to find what the problem is ??

推荐答案

查询指的是名单由检查您的搜索字词反对。你需要确保你的数据属性是对象的正确阵列(即你的选择元素)。

"Query" refers to the list by which to check your search terms against. You need to make sure that your data property is a proper array of objects (ie. your options elements).

这篇关于选择二的行为非常不同势与选择二&LT没有定义未捕获的查询功能;选择2-ID&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆