【发布时间】:2013-09-08 00:50:59
【问题描述】:
我正在使用select2 library 进行搜索。
选择搜索结果后有什么方法可以触发动作吗?例如打开一个弹出窗口,或者一个简单的 js 警报。
$("#e6").select2({
placeholder: "Enter an item id please",
minimumInputLength: 1,
ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
url: "index.php?r=sia/searchresults",
dataType: 'jsonp',
quietMillis: 3000,
data: function (term, page) {
return {
q: term, // search term
page_limit: 10,
id: 10
};
},
results: 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 remote JSON data
return {results: data};
},
},
formatResult: movieFormatResult, // omitted for brevity, see the source of this page
formatSelection: movieFormatSelection, // omitted for brevity, see the source of this page
dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
escapeMarkup: function (m) { return m; } // we do not want to escape markup since we are displaying html in results
});
【问题讨论】:
-
您可以绑定到“更改”事件,在您提供的链接上有一个名为“事件”的部分,其中包含用于所有不同事件绑定的非常长的代码 sn-p。
标签: jquery search jquery-select2