-1
我正在使用Select2 js库,但我不能将链接放入选择选项。 这里是我的JSON结构Select2转到href链接
[{id: 1, title: "Foo", slug: "foo"}]
而我选择2脚本
$(".search-box").select2({
placeholder: "Enter...",
ajax: {
url: window.location.href + '/search',
dataType: 'json',
delay: 250,
data: function (params) {
return {
q: params.term // search term
};
},
processResults: function (data) {
// 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: $.map(data, function (item) {
return {
text: item.title,
id: item.id
}
})
};
},
cache: true
},
minimumInputLength: 2,
maximumSelectionLength: 6
});
我希望当我键入并单击希望浏览器去后的地址选择适当选项的标题(链接)是
因此,任何帮助plzzz
但是...我用它,它工作正常,并且问题不在线“url:window.location.href +'/ search',” –