BootStrap select2 如何實現動態改變值
導語:BootStrap select2 如何實現動態改變值呢?下面小編給大家提供了代碼實現教程,大家可以參考閲讀,更多詳情請關注應屆畢業生考試網。
1,selec2動態賦值
var temp=JSON.stringify({ id: "1|所有停車場", name: "所有停車場" });
$("#e_pid")("value", tempP);
$("#e_pid")ct2({
placeholder: "查找停車場名稱(多選)",
language: "zh-CN",
minimumInputLength: 1,
allowClear: true,
multiple: true,
ajax: {
// instead of writing the function to execute the request we use Select2's convenient helper
url: "/manage/park/index/json/index",
dataType: 'json',
data: function (term, page) {
return {
parkName: term,// search term
powerpid: "1"
};
},
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
for (var i = 0; i < th; i++) {
data[i] = data[i]+"|"+data[i];
};
({ id: "577cb125f8d2c404572413d1|無", name: "無" });
return {
results: data
};
}
},
initSelection: function (element, callback) {
//賦初始值
// the input tag has a value attribute preloaded that points to a preselected movie's id
// this function resolves that id attribute to an object that select2 can render
// using its formatResult renderer - that way the movie name is shown preselected
var data = [];
var value = ""
var str = $(element)()t('^');
for (var i = 0; i < th; i++) {
var temp = e(str[i]);
value += + ",";
(temp);
}
;
value = tring(0, th - 1);
$(element)(value);
callback(data);
},
formatSelection: function (item) {
return ;//注意此處的name,要和ajax返回數組的鍵值一樣
}, // 選擇結果中的顯示
formatResult: function (item) {
return ;//注意此處的name
},// 搜索列表中的顯示
dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
escapeMarkup: function (m) {
return m;
}
});
2,動態改變值
$("#e_pid")("value", temp);
$("#e_pid")ger('change'); //動態改變值以後必須觸發改變時間。否則將不會生效
-
Java中如何獲取Spring中配置的bean
Spring是一個分層的JavaSE/EEfull-stack(一站式)輕量級開源框架。在Java中如何獲取Spring中配置的'bean?下面本站小編帶大家一起來看看詳細操作,希望對大家有所幫助!想了解更多相關信息請持續關注我們應屆畢業生考試網!一、什麼是Spring?Spring是一個輕量級的控...
-
全國計算機等級《二級JAVA》命題預測試卷
以下是本站小編帶來的全國計算機等級《二級JAVA》命題預測試卷,歡迎學習!更多內容請關注應屆畢業生考試網!1、軟件生命週期是指()。A.軟件產品從提出、實現、使用維護到停止使用退役的過程B.軟件從需求分析、設計、實現到測試完成的過程,C.軟件的開發過程D.軟件...
-
Java語法基礎for語句練習
本文是本站小編搜索整理的關於Java語法基礎for語句練習,供參考學習,希望對大家有所幫助!想了解更多相關信息請持續關注我們應屆畢業生考試網!控制語句——for練習語句的嵌套應用累加求和,計數器循環嵌套一、語句的嵌套應用語句嵌套形式。其實就是語句中...
-
計算機二級JAVA考試構建JAVA程序2017
很多人一見到説要編程就以為很難,其實只有一點一滴學知識點也不難,下面是小編整理的計算機二級JAVA考試構建JAVA程序介紹,歡迎閲讀!第一個javaapplicationjava程序分為javaapplication(java應用程序)和javaapplet(java小應用程序)兩種。下面讓我們編寫一個java應...
相關文章
- 三年級上冊Unit2 Colours Part B Let’s talk教學反思
- A Letter to the Editor of a Newspaper英語四級作文
- About Respecting the Old高中英語作文
- The Unforgettable School Trip英語作文
- 英語閲讀:Are You Tricked by These Optical Illusions
- 如何實現bootstrap jquery dataTable異步ajax刷新表格數據
- 六級英語寫作範文:The Celebration of Western Festivals
- 描寫飛機的英語作文:the largest carbon footprint
- 人教PEP版國小五年級英語下冊Unit3Myschoolcalender.ALet’stalk
- Covering the ears to steal the bell高中英語作文