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程序设计示例教程
本文以实例形式详细讲述了Java的反射机制,是Java程序设计中重要的技巧。分享给大家供大家参考。具体分析如下:首先,Reflection是Java程序开发语言的特征之一,它允许运行中的Java程序对自身进行检查,或者说"自审",并能直接操作程序的内部属性。例如,使用它能获得Java类...
-
如何使用java
Java是一种可以撰写跨平台应用程序的面向对象的`程序设计语言。以下是小编为大家搜索整理的如何使用java,希望能给大家带来帮助!更多精彩内容请及时关注我们应届毕业生考试网!...
-
Java工程师是做什么的
Java工程师职位描述提要:精通Java/J2EE编程,能熟练使用SpringMVC、hibernate、框架进行项目开发,熟练使用freemarker等前端模板语言。Java工程师职位描述:1、负责产品功能开发;2、遵循公司技术标准、规范,高质量完成设计、开发任务;3、参与研发部门技术积累、技术难题...
-
java与JavaScript语言有何不同
java和JavaScript是两个不同的语言。那么这两个语言有什么不同呢?下面本站小编带大家一起来看看详细内容,希望对大家有所帮助!想了解更多相关信息请持续关注我们应届毕业生考试网!讲个故事:话说很久很久以前,有一个叫网景(Netscape)的,十月怀胎,他生了个儿子,很开兴,...
相关文章
- 人教PEP版小学五年级英语下册Unit3Myschoolcalender.ALet’stalk
- About Respecting the Old高中英语作文
- 如何实现bootstrap jquery dataTable异步ajax刷新表格数据
- The Unforgettable School Trip英语作文
- 英语阅读:Are You Tricked by These Optical Illusions
- 描写飞机的英语作文:the largest carbon footprint
- Covering the ears to steal the bell高中英语作文
- A Letter to the Editor of a Newspaper英语四级作文
- 三年级上册Unit2 Colours Part B Let’s talk教学反思
- 六级英语写作范文:The Celebration of Western Festivals