[英]JQuery Select2 Can't select option
I have problem with Select2 . 我对Select2有问题。 Everything works almost fine, except i can't select any option.
一切正常,除非我无法选择任何选项。 I'm using select2 3.5.3, KnockoutJS, CoffeeScript and JQuery.
我正在使用select2 3.5.3,KnockoutJS,CoffeeScript和JQuery。 My select2 code:
我的select2代码:
generateSelect3 =->
return '<input data-bind="select2: {
data:{ results: _.available, text: \'text\'},
minimumInputLength: 3,
allowClear: true,
}" class="select2"></select>'
All files are called. 所有文件都被调用。 I have working customized select2.
我有工作定制的select2。 It's initializing code:
它是初始化代码:
generateSelect2 =->
return $('<div class="subcontainer"><input type="text" class="input-
xxlarge" data-bind="select2ex: {url: (_.params && _.params.url ||
undefined), value: value, text: text, options: _.params}"></div>');
Go to this link . 转到此链接 。 You need to link only 2 files.
您只需要链接2个文件。 Css on Head and Js on footer.
头上的Css和页脚的Js。
Call your personal js file after select2.js, and you must call jQuery.js
before select2.js
. 在select2.js之后调用您的个人js文件,并且您必须在
jQuery.js
之前调用select2.js
。
Use the below code on your file. 在文件上使用以下代码。
$(document).ready(function () {
$(".category").select2({
placeholder: 'Category',
tags: true,
width: 'resolve'
});
$(".sub-category").select2({
placeholder: 'Sub Category',
tags: true,
width: 'resolve'
});
});
Problem solved: 问题解决了:
return $('<div class="subcontainer"><select
class="input-xxlarge"
data-bind="options: _.available,
optionsText: $.ehr.CodedWidget.formatSelectText,
optionsValue: function(item) {
return item && item.value || (item.value == 0 ? item.value + \'\' : \'\') },
select2ex: {
value: value,
}"></select></div>')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.