【发布时间】:2015-08-23 02:13:36
【问题描述】:
我正在尝试设置连接到 Ajax 数据源的 Select2 元素的初始值。
我正在使用 Select2 的 v4,并遵循 the docs,这说明 initSelection 已被替换。
我已经开始尝试适应the example in the "Loading remote data" section of the Select2 documentation。这是我设置初始值的代码:
var $gitElement = $('.select2');
var option = new Option("yosssi/ejr", '29424443', true, true);
$gitElement.append(option);
$gitElement.trigger('change');
我最终得到一个显示undefined (undefined) 的标签。我做错了什么?
JSFiddle 在这里:http://jsfiddle.net/t4Ltcm0f/4/
【问题讨论】:
标签: javascript jquery ajax jquery-select2 jquery-select2-4