jquery插件select2事件不起作用(select2-3.5.4)
jquery插件select2事件不起作用
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
蕃薯耀 2015年10月8日 09:01:53 星期四
http://fanshuyao.iteye.com/
一、官网的说明:https://select2.github.io/examples.html(Version 4.0.0)
change is fired whenever an option is selected or removed.
select2:open is fired whenever the dropdown is opened. select2:opening is fired before this and can be prevented.
select2:close is fired whenever the dropdown is closed. select2:closing is fired before this and can be prevented.
select2:select is fired whenever a result is selected. select2:selecting is fired before this and can be prevented.
select2:unselect is fired whenever a result is unselected. select2:unselecting is fired before this and can be prevented.
二、官网的使用例子:
- var $eventLog = $(".js-event-log");
- var $eventSelect = $(".js-example-events");
- $eventSelect.on("select2:open",function(e){ log("select2:open", e);});
- $eventSelect.on("select2:close",function(e){ log("select2:close", e);});
- $eventSelect.on("select2:select",function(e){ log("select2:select", e);});
- $eventSelect.on("select2:unselect",function(e){ log("select2:unselect", e);});
- $eventSelect.on("change",function(e){ log("change");});
但是在实际应用中select2:close不起作用。
三、解决方法:
这个原因找了很久都没有找到,昨天终于发现原因了:
$("#xxx").on("select2-close", function (e) {
});
原来是select2-close,中间的不是冒号,而是 - (横杠),修改后就能使用了
jquery.validate.js插件也能完善校验。
$("#genders").on("select2-close", function (e) {
$(this).valid();
});
最终原因是select2的版本问题
在3.5.4版本中的事件为:
Events
change
Fired when selection is changed.
The event object contains the following custom properties:
select2-opening
Fired before the dropdown is shown.
The event listener can prevent the opening by calling preventDefault() on the supplied event object.
select2-open
Fired after the dropdown is shown.
select2-close
Fired after the dropdown is closed.
select2-highlight
Fired when a choice is highlighted in the dropdown.
The event object contains the following custom properties:
select2-selecting
Fired when a choice is being selected in the dropdown, but before any modification has been made to the selection. This event is used to allow the user to reject selection by calling event.preventDefault()
The event object contains the following custom properties:
select2-clearing
Fired when a choice is being cleared in the dropdown, but before any modification has been made to the selection. This event is used to allow the user to reject the clear by calling event.preventDefault()
For the clear button to be visible the allowClear option needs to be true.
select2-removing
Fired when a choice is about to be removed in the dropdown/input, but before any removal of the choice has been made. This event is used to allow the user to reject removal by calling event.preventDefault()
The event object contains the following custom properties:
select2-removed
Fired when a choice is removed or cleared.
The event object contains the following custom properties:
select2-loaded
Fired when query function is done loading the data and the results list has been updated
The event object contains the following custom properties:
select2-focus
Fired when the control is focussed.
select2-blur
Fired when the control is blurred.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
蕃薯耀 2015年10月8日 09:01:53 星期四
http://fanshuyao.iteye.com/
jquery插件select2事件不起作用(select2-3.5.4)的更多相关文章
- jQuery插件 -- 动态事件绑定插件jquery.livequery.js
http://blog.csdn.net/zzq58157383/article/details/7721974 动态事件绑定插件livequery, 可以利用它给相应的DOM元素注册事件或者触发回调 ...
- jquery插件获取事件类型
//需要在使用函数时传入event关键字 $('[name=lprice]').change(function(event){ $('[name=lprice]').validate({ event: ...
- jquery的return this.each()的作用
经常看到在运用jquery插件绑定事件时候,都会用到each. 下面来比较下使用return this和return this.each()在使用的区别. 注意:使用each的时候引用this,必须使 ...
- jquery.validate.js校验select2解决方案,Jquery插件select2校验解决方案
jquery.validate.js校验select2解决方案 Jquery插件select2校验解决方案 >>>>>>>>>>>&g ...
- html select美化模拟jquery插件select2.js
代码展示:http://www.51xuediannao.com/demo.php 代码说明: select2.js是一个html select美化模拟类jquery插件,但是select2.js又远 ...
- jQuery插件select2跨域设置xhrFields参数
ajax跨越时默认不带cookie,如果需要带cookie调用,需要设置参数 xhrFields: { withCredentials: true },如: $.ajax({url : "h ...
- 详解jquery插件中;(function ( $, window, document, undefined )的作用
在jquery插件中我们经常看到以下这段代码 1 2 3 ;(function ( $, window, document, undefined ){ //函数体内具体代码 })(jQuery, wi ...
- jquery插件中(function ( $, window, document, undefined )的作用
在jquery插件中我们经常看到以下这段代码 ;(function ( $, window, document, undefined ){ //函数体内具体代码 })(jQuery, window,d ...
- 详解jquery插件中(function ( $, window, document, undefined )的作用。
1.(function(window,undefined){})(window); Q:(function(window,undefined){})(window);中为什么要将window和unde ...
随机推荐
- TF卡的Class4/Class6/Class10
TF卡全称TransFlash卡,即T-Flash又称MicroSD,随设备微型化的需要,TF卡用途越来越广,速度也越来越快,从最初的Class2早已发展到目前主流的Class10,TF卡体积为15m ...
- 忽然想到,为什么以前iOS的工资高
听说做iOS的在上海工资也可以 前几年还行,现在也不太行了除非你水平很高 现在移动应用已经100多万了,基本饱和了以前是新的商业模式要抢时间,会的人也少
- android使用webview上传文件(支持相册和拍照)
老夫最近需要做一个项目,需要调用服务器段的一些网页来选择文件,刚开始还挺纠结的,不知从何下手,网上大致预览了大神们走过的路,他们传统的方式都是使用一下代码: public void openFileC ...
- XUTils框架的学习(三)
前面两章说了xutils框架的引入和注解模块的使用和数据库模块的使用,想了解的朋友可以去看看. 前面在说数据库模块的操作的时候是手动创建数据库并保存在asset文件夹里面,再通过I/O将数据库写进应用 ...
- linux修改主机名
查看机器名:uname -a 修改机器名: redhat中修改主机名 第一步:#hostname oratest 第二步:修改/etc/sysconfig/network中的hostname 第三步: ...
- [App]Taste VS2015 && Android Studio
逆水飞 尝试进行各种Android开发工具的安装以及大致流程对比 几个疑惑的地方 1)根据SDK的描述,应该是一个新版本的推出就有对应的包里面包含多个文件那么对于:SDK Platform.APIs. ...
- [CODEVS3641]上帝选人
题目描述 Description 世界上的人都有智商IQ和情商EQ.我们用两个数字来表示人的智商和情商,数字大就代表其相应智商或情商高.现在你面前有N个人,这N个人的智商和情商均已知,请你选择出尽量多 ...
- 线程中Join的使用例子
1.实现Runnbale接口, package 网易若干java;//这个例子共有2个线程,一个是主线程,一个是线程t public class MyThread1 implements Runnab ...
- rman进行备份、恢复
rman备份可以很复杂,但学习需要由浅入深,下面是最常见的几种备份.恢复方式. 备份数据的路径与大小: SQL> show parameter DB_RECOVERY_FILE_DEST NA ...
- clas