select2

select2多选设置select多选,select2取值和赋值

独自空忆成欢 提交于 2019-12-06 12:44:05
select2设置select多选,select2取值和赋值,作为筛选条件的时候,取值相对简单,把选中的id值转为字符串传给后端查询,查询之后会刷新页面,为了在下拉框中显示刚刚选中的值,就需要给select赋值,可以将刚才传给后端的字符串再传回前端,然后转为一位数组,再赋值给select2就会显示刚刚选中的值,赋值方法:$('#id').val(arr).trigger('change'),id为select的id属性,这里的arr是刚才从后端传回前端的id转成的一位数组。 select2设置select多选,select2取值和赋值,首先需要引入select2的js文件, select2官网地址 : https://select2.org/ //select2html代码设置选项,list为后端查询出来的选项,循环赋值 < select name= "id" id= "id" multiple= "multiple"> < option value= "0">请选择部门 </ option> < volist name= "list" id= "vo"> < option value= "{$vo.id}" < eq name= "vo.id" value= "$id">selected = "selected" </ eq>>{$vo.name} </ option> </

Using Select2 (multiple selections) with vue.js

久未见 提交于 2019-12-06 07:21:34
I'm new to vue and have followed their 'custom directive' at http://vuejs.org/examples/select2.html . This works well when only selecting one item, but when you're selecting multiple items it only passes the first one. I need it to pass all values selected. I have a jsfiddle set up displaying the code which is available here. https://jsfiddle.net/f3kd6f14/1/ The directive is as below; Vue.directive('select', { twoWay: true, priority: 1000, params: ['options'], bind: function() { var self = this $(this.el) .select2({ data: this.params.options }) .on('change', function() { self.set(this.value) }

select2的学习和jqgrip的学习

喜你入骨 提交于 2019-12-06 02:22:33
s elect2的例子: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>select2的学习</title> <script> remoteToLoadCss('BootStrap4/assets/plugins/bootstrap-datepicker/old_datepaker/datepicker.css'); remoteToLoadJs('media/js/jquery-1.11.1.js'); remoteToLoadJs('BootStrap4/assets/plugins/bootstrap-datepicker/old_datepaker/bootstrap-datepicker.js'); remoteToLoadJs('BootStrap4/assets/plugins/bootstrap-datepicker/old_datepaker/bootstrap-datepicker.zh-CN.min.js'); </script> <script src="../../../js/select2.min.js"></script> <link href="../../../css/select2.min.css" rel="stylesheet"> </head>

How to set select value in select2 plugin - jquery

拟墨画扇 提交于 2019-12-05 12:20:15
I use this code for insert data to select element with select2 plugin: $.ajax({ type: "POST", url: "ws.asmx/GetEvrakGrup", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (dc, status) { jsonData = JSON.parse(dc.d); $("#selectId").select2({ data: jsonData }); }, error: function () { alert("This is an Error");} }); After I want to set a value in this select but its not working: $("#selectId").val(81); Try this : $("#selectId").val(81).trigger('change'); Instead of $("#selectId").val(81); try below code: var $example = $("#selectId").select2();

select2 控件在jquery-ui dialog下无法搜索问题解决

两盒软妹~` 提交于 2019-12-05 02:35:58
今天,使用select2控件,动态加载select标签的数据,其强大的展示,搜索功能非常好用。 但是在dialog弹出框中,可以选择,但是无法搜索,焦点一直在弹出框的第一个input上。 百度一下找到的解决方法。就是重写一下dialog控件。 网上的解决方法如下: 1.问题呈现 项目中使用了jQuery UI的Dialog控件,一般用来处理需要提示用户输入或操作的简单页面。逻辑是修改一个广告的图片和标题。 效果截图如下: 使用Select2,主要是因为它支持下拉式搜索。所以在数据稍微多一点,作为搜索选择功能的首选。但是运行出来之后,发现搜索框无法点击。开始想到的index不够大,被其他的元素覆盖了。但是跳转z-index也无法解决。在普通的页面,搜索框是ok的。 2.解决办法 通过Google搜索,发现select2作者在github上说明了这个问题: 但是他给出解决的方法,我看不太懂,后面也有人说直接修改jQuery UI类库,但是我们项目中使用的jquery-ui-1.10.3.min.js。所以不可能修改jQuery UI的源代码,而已修改源代码,在后期类库升级和维护上,各种坑还是比较多。所以我继续搜索解决版本。在jQuery UI的官网找到了方法。hot fix代码如下: hot fix:Select2控件在jQuery UI弹出对话中不能搜索 $.widget("ui

How to change font color of select2 control using css

旧巷老猫 提交于 2019-12-04 14:36:31
I am using the following HTML code to include a select2 control in my form as below. <select id="element_id" class="select2" style="width:100%"> <option value="e1" >Element 1</option> <option value="e2" >Element 2</option> <option value="e3" >Element 3</option> </select> I am using the following style to format the font of the list items and selected item. <style> #s2id_element_id .select2-container--default .select2-selection--single .select2-selection__rendered { color: green ; } </style> This does not color the list items and selected item in green color. Note: I only need this specific

select2的简单使用

最后都变了- 提交于 2019-12-04 11:31:38
显示品牌下拉列表(静态) ( 1 )修改 type_template.html 引入 JS <!-- slect2插件--> < link rel= "stylesheet" href= "../plugins/select2/select2.css" /> < link rel= "stylesheet" href= "../plugins/select2/select2-bootstrap.css" /> < script src= "../plugins/select2/select2.min.js" type= "text/javascript" ></ script > < script src= "../plugins/angularjs/angular.min.js" ></ script > < script src= "../js/base_pagination.js" ></ script > <!-- 导入select2-angula--> < script src= "../js/angular-select2.js" ></ script > < script src= "../plugins/angularjs/pagination.js" ></ script > < link rel= "stylesheet" href= "../plugins

how to tell elm about external DOM changes

本秂侑毒 提交于 2019-12-04 04:00:47
问题 I'm using elm 0.17.1 and trying to interop with select2 javascript library(version 4.0.3), here is my Main.elm : port module Main exposing (..) import Html exposing (Html,select,option,div,text,br) import Html.App as App import Html.Attributes exposing (id,value,width) -- MODEL type alias Model = { country : String } -- UPDATE type Msg = Select String update : Msg -> Model -> (Model, Cmd Msg) update msg model = case msg of Select str -> (Model str,Cmd.none) -- VIEW view : Model -> Html Msg

How to use Select2 with Reactjs?

霸气de小男生 提交于 2019-12-04 02:53:54
I have dependent fields like this <List> <select> <option></option> <option></option> </select> <select> <option></option> <option></option> </select> <input /> </List> If I had 5 <List/> components.How do I add Select2 to each component.I googled online.But couldn't find any working solution. Code below for react-select .Getting error TypeError: event.target is undefined . var React = require('react'); var ReactDOM = require('react-dom'); var Select = require('react-select'); var Page = React.createClass({ getInitialState: function () { return { firstValue: '' } }, handleFirstLevelChange :

How to remove selected option from the option list in select2 multiselect and show selected options in the order they are selected

天大地大妈咪最大 提交于 2019-12-03 11:00:47
问题 I have select2 multi select field in my form where I want to remove the selected option from the dropdown list after it is selected and again add it to the list if it is removed from the list. And also the added items should be in the same order as they selected. The current select2 (4.0) is not removing the selected the items and and it is showing the selected items in the order they appear in the drop down list, not in the order they are selected. $(document).ready(function(){ $('