Multiselect

简介:

LINK:http://demo.mycodes.net/daima/Multiselect/;

HTML

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
< div  class = "muti-sel" >
     < div  class = "col-xs-5" >
         < select  name = "from[]"  id = "keepRenderingSort"  class = "form-control"  size = "8"  multiple = "multiple" >
             < option  value = "1" >Item 1</ option >
         < option  value = "2" >Item 5</ option >
         < option  value = "2" >Item 2</ option >
             < option  value = "2" >Item 4</ option >
             < option  value = "3" >Item 3</ option >
         </ select >
     </ div >
     < div  class = "col-xs-2" >
         < button  type = "button"  id = "keepRenderingSort_rightAll"  class = "btn btn-block" >< i  class = "glyphicon glyphicon-forward" ></ i ></ button >
         < button  type = "button"  id = "keepRenderingSort_rightSelected"  class = "btn btn-block" >< i  class = "glyphicon glyphicon-chevron-right" ></ i ></ button >
         < button  type = "button"  id = "keepRenderingSort_leftSelected"  class = "btn btn-block" >< i  class = "glyphicon glyphicon-chevron-left" ></ i ></ button >
         < button  type = "button"  id = "keepRenderingSort_leftAll"  class = "btn btn-block" >< i  class = "glyphicon glyphicon-backward" ></ i ></ button >
     </ div >
     < div  class = "col-xs-5" >
         < select  name = "to[]"  id = "keepRenderingSort_to"  class = "form-control"  size = "8"  multiple = "multiple" ></ select >
     </ div >
</ div >

js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$( '#keepRenderingSort' ).multiselect({
     keepRenderingSort:  true ,
     afterMoveToRight:  function ($left, $right, option){
         var  sel_val = option.val();
                     
     },
     afterMoveToLeft:  function ($left, $right, option){
     }
});
$( '#keepRenderingSort' ).multiselect({
     right:  '#js_multiselect_to_1' ,
     rightAll:  '#js_right_All_1' ,
     rightSelected:  '#js_right_Selected_1' ,
     leftSelected:  '#js_left_Selected_1' ,
     leftAll:  '#js_left_All_1'
});


参数

Name type default description
right stringjQuery selector multiselect_id_to The select where the options are moved to
rightSelected stringjQuery selector multiselect_id_rightSelected The button that moves selected options from left to right
rightAll stringjQuery selector multiselect_id_rightAll The button that moves all options from left to right
leftSelected stringjQuery selector multiselect_id_leftSelected The button that moves selected options from right to left
leftAll stringjQuery selector multiselect_id_leftAll The button that moves all options from right to left
startUp function orfalse remove from left all options that are present in right Whatever you want to do with $left and $right elements when the multiselect plugin is initialised
sort function orfalse sort options alphabetically Will sort options when an action happend into right or left elements.
beforeMoveToRight function return true Whatever you want to do with $left$right and option[s] elements before they are moved to right. Keep in mind that this function must return a boolean value.
true will let the action to be performed.
false will stop the action
afterMoveToRight function no action Whatever you want to do with $left$right and option[s] elements after they are moved to right.
beforeMoveToLeft function return true Whatever you want to do with $left$right and option[s] elements before they are moved to left. Keep in mind that this function must return a boolean value.
true will let the action to be performed.
false will stop the action
afterMoveToLeft function no action Whatever you want to do with $left$right and option[s] elements after they are moved to left.
keepRenderingSort boolean false When you want to keep options sorted as they was rendered, keepRenderingSort must be true.
When keepRenderingSort is truesort function will be ignored.


本文转自 爱笑嘚蛋蛋 51CTO博客,原文链接:http://blog.51cto.com/dd118/1880614,如需转载请自行联系原作者

相关文章
|
7月前
|
Java 容器 Spring
DefaultListableBeanFactory
DefaultListableBeanFactory 是一个完整的、功能成熟的 IoC 容器,如果你的需求很简单,甚至可以直接使用 DefaultListableBeanFactory,如果你的需求比较复杂,那么通过扩展 DefaultListableBeanFactory 的功能也可以达到,可以说 DefaultListableBeanFactory 是整个 Spring IoC 容器的始祖。
|
7月前
|
JavaScript 前端开发
Warning: Invalid DOM property `allowfullscreen`. Did you mean `allowFullScreen`?
这个警告信息是关于一个常见的拼写错误。DOM(Document Object Model)属性 `allowfullscreen` 是不正确的,正确的属性名应该是 `allowFullScreen`。 当你在JavaScript中尝试使用 `allowfullscreen` 属性时,你可能会遇到这个警告。为了解决这个问题,你应该将属性名更正为 `allowFullScreen`。 例如,如果你原本的代码是这样的: ```javascript element.allowfullscreen = true; ``` 你应该更正为: ```javascript element.allow
|
7月前
|
前端开发 JavaScript 算法
shouldComponentUpdate 是做什么的?
shouldComponentUpdate 是做什么的?
183 0
Warning: [antd: Form.Item] `defaultValue` will not work on controlled Field. You should use `initialValues` of Form instead.
Warning: [antd: Form.Item] `defaultValue` will not work on controlled Field. You should use `initialValues` of Form instead.
772 0
A. Calculating Function
A. Calculating Function
50 0
|
JavaScript 程序员
使用MultiSelect左右选择控件的一些设计
项目中用到左右选择的控件,网上查找了一些相关的实现,结合了一下
183 0
使用MultiSelect左右选择控件的一些设计
|
缓存 JavaScript Go
你真的了解esModule吗
项目中我们常常会接触到模块,最为典型代表的是esModule与commonjs,在es6之前还有AMD代表的seajs,requirejs,在项目模块加载的文件之间,我们如何选择,比如常常因为某个变量,我们需要动态加载某个文件,因此你想到了require('xxx'),我们也常常会用import方式导入路由组件或者文件,等等。因此我们有必要真正明白如何使用好它,并正确的用好它们。
110 0
Calculating Function
Calculating Function
95 0
Calculating Function
|
JavaScript 安全 前端开发
What Is ElectronJS and Why Should You Use It?
In this three-part tutorial, we will explore how to create a fully functional invoice application using ElectronJS and ApsaraDB for MongoDB.
2661 0
What Is ElectronJS and Why Should You Use It?