Home  >  Article  >  Web Front-end  >  A brief analysis of the problem of data binding in Bootstrip's select control_jquery

A brief analysis of the problem of data binding in Bootstrip's select control_jquery

WBOY
WBOYOriginal
2016-05-16 09:00:132695browse

this problem took me a whole afternoon to figure out, and i finally solved it. the editor will share my credit below as a backup, and i hope it can help everyone.

the specific details are as follows:

$(function(){ 
var stu_no = freeUrl();
var data, subname="",data2;
var sbList = new Array();
$.ajax({ 
async: false ,
dataType: "json",
contentType: "application/json",
type: "post",
url: "../../control/student/stuMain.asmx/findAllSubject",
data:"{"+"'stu_no':'"+stu_no+"'}",
success: function (response) {
data2 = eval(response.d);
$.each(data2, function (i) {
$("<option value='" + i + "'>" + data2[i].科目名称 + "</option>").appendTo(".selectpicker");
});
$('.selectpicker').selectpicker({
//我是对所有的selectpicker操作一次性赋值,如果你想单独赋值,好ok,那么就这样赋值:
//appendTo("#editcolor .selectpicker"),就这样,在你select元素上面罩上一个div,
//用div的id就可以标记你要操作的selectpicker,也就是你想操作的select元素标签了
style: 'btn-info',
size: 8
})
}
})

the above is the editor's introduction to the issue of data binding in bootstrip's select control. i hope it will be helpful to you!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn