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 ...
随机推荐
- decode_json 必须是unicode形式的字符
centos6.5:/root/test#cat a1.pl use JSON qw/encode_json decode_json/; use Encode; my $data = [ { 'nam ...
- css全局设置
/***** 全局设置 *****/ body,h1,h2,h3,h4,h5,h6,p,form,ul,ol,li,dt,dl,dd,th,td,label,bottom,input,textar ...
- linux必会的60个命令
◆ 安装和登录命令:login.shutdown.halt.reboot.install.mount.umount.chsh.exit.last: ◆ 文件处理命令:file.mkdir.grep.d ...
- 新一批电子商务解决方案和企业管理应用加入 VM Depot 中国站点
新一批电子商务解决方案和企业管理应用加入 VM Depot 中国站点. //电子商务平台助力您建设网店// 大约有 6 个最近更新的电子商务程序包已经登陆 VM Depot. 这不仅囊括了全球知 ...
- Ora-12154:无法解析连接字符串
服务器的环境为: 系统:Windows server 2008 64位 数据库:Oracle 10g WEB应用服务:IIS 7.0+.Net Framework 4.0 解决方法 Toad for ...
- Linux下Java环境变量设置
我用的是oh my zsh,需要修改.zshrc,记一下免得以后忘记在哪儿改的. 如果你用的是自带的terminal那么用文本编辑器打开用户目录下的.bash_profile文件 在.bash_pro ...
- 全新ASP框架——IISNODE介绍
Asp是一门经典的动态网页编程语言,通常使用vbscript或者Jscript脚本来实现.一个好的框架,可以帮助您更加快速地使用Asp来完成您的网站开发任务.而Asp框架的终结者——IISNODE框架 ...
- Hadoop 配置好hive,第一次在conf能进入,第二次就不行了,怎么办?
问题描述: 在 Hadoop 配置好 hive 数据仓库,在conf目录下通过hive命令进入hive数据仓库,非常顺利. 但关闭终端,第二次按这种方式却显示,无次命令. 怎么办? 解决办法: 在h ...
- C随便练练手的题
判断101-200之间有多少个素数,并输出所有素数 #include <stdio.h> int main(){ ; ; ; ){ while(may<cur){ ){ break; ...
- Struts标签<s:iterator>遍历访问复杂Map对象
<s:iterator value="resultType" id="geneUi"> //拿到要遍历的Map对象 <s:iterator v ...