【发布时间】:2015-02-14 09:55:08
【问题描述】:
Select2 - 版本 4.0.0-beta.3
我正在努力将我的Select2 从 3 升级到 4.0。我在使用 Select2 处理 ajax 请求时遇到问题。
我有以下领域。
HTML
<input action="load_users" id="id_pic_credits" name="pic_credits" type="hidden">
JS
$(document).ready(function () {
$("*[action='load_users']").select2({
allowClear: true,
width: '100%',
multiple: false,
minimumInputLength: 1,
"ajax": {
"url": _url,
delay: 250,
dataType: "json",
data: function (search, page) {
return search
},
processResults: function (data, page) {
// parse the results into the format expected by Select2.
// since we are using custom formatting functions we do not need to
// alter the remote JSON data
return {
results: data.items
};
},
cache: true
}
});
});
HTML 结果
服务器响应
List of dicts.
[{'id':1, 'text':'Ray of Peace'},{'id':2, 'text':'Ray of Peace2'}]
HTML 结果
问题
当我点击任何记录时;我看不到该值是否实际上正在被选中。 当下拉关闭时;我没有看到选定的值。 但是,该字段的值在 HTML 中发生了更改;但我看不到结果。
【问题讨论】:
标签: javascript jquery html jquery-select2