select2

select2

匿名 (未验证) 提交于 2019-12-03 00:37:01
研究了3个小时, 最后使用$.ajax 重新加载原始值. 并显示. //two AJAX获取数据方式(每次请求) var $c_HospitalCode = $( "#c_HospitalCode" ).select2({ ajax: { type: 'GET' , url: "/Report/AjaxOption/Ajax_LoadHospitalByKey" , dataType: 'json' , delay: 400 , data: function (params) { return { key: params.term, // search term 请求参数 page: params.page, MKORGCode: '@VModel.MKORGCode' }; }, processResults: function (data, params) { //重命名字段名 for ( var i = 0 ; i < data.length; i++) { data[i].id = data[i].Value; data[i].text = data[i].Name; } //params.page = params.page || 1; return { results: data //,//itemList //pagination: { // more:

angularjs完整demo例子

匿名 (未验证) 提交于 2019-12-02 23:57:01
 AngularJS的主要特点是 mvc 数据双向绑定 分模块 依赖注入      mvc m: $Scope 变量 V:视图 c:controller=function(){} 控制器 方法      Angularjs的用法 1.在一个有起始标签的元素开始标签内使用 ng-app来指定angularjs的作用范围 2.angularJS的表达式是双大括号 {{}} 里面可以显示变量,数学运算,执行方法 3.ng-model=“变量名” 在输入框内可以绑定一个变量,此变量前端输入的值和js代码中的值是双向绑定的,一个变了都变了,并且使用此变量的地方都发生改变 4.ng-init=“变量名=‘变量值’” 一般加在body的起始标签内 初始化变量 也可以初始化方法 相当于onload方法      通常一个项目有一个angularJS模块,一个页面又一个angularJS的控制器 ng-app=“模块名” ng-app后面也可以指定模块名,如果定义控制器必须先定义模块对象,模块对象必须有名字 如果不定义控制器简单实用angularJS则直接ng-app指定作用范围也可      定义模块及定义控制器需要在js代码块中完成 在body属性里只能指定模块的名字和控制器的名字以及简单的使用      var app=angular.module(‘模块名’,[‘引入的模块名’])

BootStrap之X-editable插件使用

匿名 (未验证) 提交于 2019-12-02 23:56:01
项目背景 步骤 1、jsp中添加引用 <link type= "text/css" href= "${ctx}/static/comp/jquery-ui-bootstrap/css/bootstrap-editable.css" rel= "stylesheet"> < script src= "${ctx}/static/comp/jquery-ui-bootstrap/js/bootstrap-editable.js" type= "text/javascript"> </ script> 2、在jsp中编写代码 <c:forEach items= "${page.result}" var= "m" varStatus= "status"> < tr> < td columnName= "operator"> < a href= "#" class= "employee" value= "" data-pk= "operator" data-type= "select2">${m.employeeNo} </ a> </ td> </ tr> < /c:forEach> /** * table行内编辑事件,化验员单元格编辑事件 */ $( '.employee').editable({ //employee标签 type: "select2", //编辑框的类型--多选框

select2插件在modal(模态框)中无法聚焦

匿名 (未验证) 提交于 2019-12-02 23:43:01
这个问题在碰到开发过程中遇到过了,网上给出大多数做法都是在ready中加入以下代码: $.fn.modal.Constructor.prototype.enforceFocus = function() {}; 后来在加班select2官网文档的时候,发现在4.0以后的版本,官方已经意识到了这个问题 并迅速的给出了解决办法 $('#mySelect2').select2({ dropdownParent: $('#myModal') }); 文章来源: https://blog.csdn.net/qq_31281189/article/details/92566372

Select2异步搜索数据

匿名 (未验证) 提交于 2019-12-02 21:53:52
$('#countryID').select2( { placeholder: "请选择国家", ajax: { dataType: 'json', type: 'POST', delay: 500, data: function (params) { return { SearchKey: params.term //params.term 搜索参数值 }; }, transport: async function (params, success, failure) { //这个params和上个params是不太一样,建议 console.log(params) if (typeof (params.data.SearchKey) == "undefined") { //刚聚焦是参数值是undefined的 var data = await vm.searchCountries({}); //data是返回的绑定数据,json数组 [{"ComapnyDistrictCode":[],"ParentID":"0","Name":"阿富汗伊斯兰国"},{...}] if (data && data.length > 0) { success(data);                     //插件自带的回调success函数, } else { failure(); }

jQuery 插件

戏子无情 提交于 2019-12-02 16:54:06
jQuery 插件 1 jQuery 插件的网站 http://plugins.jquery.com/ 官网 http://www.jq22.com/ jQuery插件库 http://www.htmleaf.com/ jQuery 之家 http://www.jq-school.co m jQuery-school 2 经典jQuery插件 2.1 ### select2 下拉框搜索插件 官网 https://select2.org/ github https://github.com/select2/select2 用法 $(dom).select2() $(dom).select({ width:, data:, ajax:, .... }) 2.2 datetimepicker 时间日期插件 github https://github.com/xdan/datetimepicker 文档 https://xdsoft.net/jqplugins/datetimepicker/ 用法 //设置语言 $.datetimepicker.setLocale('zh'); //调用插件 $(dom).datetimepicker({ datepicker:, timepicker:, format:"Y-m-d H:i", value:, .... }) 2.3 fullpage

Select2 - Searching wildcard matches

為{幸葍}努か 提交于 2019-12-02 11:25:48
问题 I am using Select2 to style my select box and add functionality and I am wondering how I can make the search rules more lenient. Currently if I have "New Mexico" in the dropdown, I can search for "mexico" or "new mexico" to match the select option, but if I enter "mexico new" I get "no results found." Is there a way to extend the search functionality to match search words regardless of their order? $(document).ready(function() { $(".states").select2(); }); <script src="https://ajax.googleapis

Select2 - Searching wildcard matches

ぃ、小莉子 提交于 2019-12-02 05:44:11
I am using Select2 to style my select box and add functionality and I am wondering how I can make the search rules more lenient. Currently if I have "New Mexico" in the dropdown, I can search for "mexico" or "new mexico" to match the select option, but if I enter "mexico new" I get "no results found." Is there a way to extend the search functionality to match search words regardless of their order? $(document).ready(function() { $(".states").select2(); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax

How to append jquery select2 values with initSelection

梦想与她 提交于 2019-12-02 02:03:41
Here is my select2 multiple select with ajax. Initially i am setting some values in the initselection like this initSelection : function (element, callback) { var data = {id: 4, zipcode: "00602"}; callback(data); }; And then i am doing the ajax selection. But i can't able to sustain the old values. i.e., when i type the new selection, the old values are replaced instead of appending . Here is my entire code. var $select = $('#firstList'); $select.select2({ placeholder : "Enter Pincode", allowClear : true, cache : true, initSelection : function(element, callback) { var data = { id : 4, zipcode

Select2 jquery plugin show number of selected items in the result instead of tags

只愿长相守 提交于 2019-11-30 18:20:06
I am using Select2 jQuery Plugin . https://select2.github.io/ for reference When I am using the multiple dropdown option. The result of selected items is shown as tags in a box but, I just want to show the number of items selected. Is it possible with Select2 jQuery plugin HTML <select multiple style="width:100%"> <option value="1">Name1</option> <option value="2">Name2</option> <option value="3">Name3</option> <option value="4">Name4</option> <option value="5">Name5</option> <option value="6">Name6</option> <option value="7">Name7</option> </select> JS $('select').select2(); I want output as