jQuery的带搜索过滤ajax加载下拉框插件
这是一款支持选项搜索过滤和Ajax远程加载的select下拉选择框jQuery插件。
js代码
/* This parser won't respect "---" selection */
function dataParserA(data, selected) {
retval = [ { val: "-1" , text: "---" } ];
data.forEach(function(v){
if(selected == "-1" && v.val == 3)
v.selected = true;
retval.push(v);
});
return retval;
}
/* This parser let's the component to handle selection */
function dataParserB(data, selected) {
retval = [ { val: "-1" , text: "---" } ];
data.forEach(function(v){ retval.push(v); });
return retval;
}
/* Create select elements */
$("#select1").tinyselect();
$("#select2").tinyselect({ showSearch: false });
$("#select3").tinyselect({ dataUrl: "file.json" , dataParser: dataParserA });
$("#select4").tinyselect({ dataUrl: "failure.json" });
$("#select5").tinyselect({ dataUrl: "file.json" , dataParser: dataParserB });
$("#select2").on("change",function() {
console.log($(this).val());
});
$("#havoc").show()
申明:本站所有资源都是转载各大下载站,或由网友投稿发布,请自行检测软件的完整性,如有侵权请联系我们删除下架,联系方式:admin@php.cn