Git Product home page Git Product logo

search-select's Introduction

search-select

表单Select,可搜索选中,支持Ajax搜索或初始化数据源,不依赖JQuery
例子见 查看示例

功能

  • 数据源搜索
  • Ajax搜索
  • 自定义展示名称
  • 设置区分大小写
  • 自定义搜索字段
  • 自定义选中值
  • 自定义回调函数

例1数据源

	var config1 = {
		targetEle:document.getElementById("search-select1"),//dom
		field:"name",//默认下拉展示数据
		dataValue:"id",//li data-value值
		filterColumn: ['key','name'],//搜索字段
		sensitive: true,//是否区分大小写
		sourceData:[{name:"search",key:'I',id:123},{name:"select",key:'He',id:456},{name:"search-select",key:'You',id:789}],//数据源
	}
	var searchSelect1 = new SearchSelect(config1);
	searchSelect1.selectCallBack = function (data) {
		alert(JSON.stringify(data));
	}

例2AJAX

var config = {
		targetEle:document.getElementById("search-select"),
		field:"name",//默认展示字段、搜索字段
		dataValue:"id",//下拉选项data-value值,默认data-array-num=顺序
		//eg:<li data-array-num="0" data-value="123">search</li>
		getData:getData,//AJAX搜索函数
		isAjax: true//默认false 非AJAX
	}
	var searchSelect = new SearchSelect(config);//初始化对象
	searchSelect.selectCallBack = function (data) {//选中回调函数
		alert(JSON.stringify(data));
	}
	function getData(keyword) {
		//jquery方法
		var url = '',data={keyword:keyword};
		$.post(url, data, function(data){
			searchSelecti.pushData(data);//添加数据结果
		}, 'json');
	}

Other

简简单单临时项目需求,没太优化

search-select's People

Contributors

tuine avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.