本文介绍了Select2的行为与未为Select2< select2-id>定义的Uncaught查询功能非常不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我按以下方式加载select2的值。
I load values for select2 like the following way.
声明类型
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>
当我为第一个加载它时它没有给出任何异常但是如果我刷新
或导航到不同的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
推荐答案
查询是指用于检查搜索条件的列表。您需要确保 data
属性是一个正确的对象数组(即您的选项元素)。
"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).
这篇关于Select2的行为与未为Select2< select2-id>定义的Uncaught查询功能非常不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!