jQuery带搜索过滤ajax加载下拉框插件

jQuery带搜索过滤ajax加载下拉框插件-精品资源网
jQuery带搜索过滤ajax加载下拉框插件
此内容为免费资源,请登录后查看
0
免费资源

jQuery带搜索过滤ajax加载下拉框插件

这是一款支持选项搜索过滤和Ajax远程加载的select下拉选择框jQuery插件。

js代码

<script src=\"js/jquery-1.11.0.min.js\" type=\"text/javascript\"></script>
<script src=\"js/tinyselect.js\"></script>
<script>
/* 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()

</script>

© 版权声明
THE END
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容