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/
相关推荐
apache-maven-3.5.4-bin.tar.gz的插件,在Mac本下的使用,可以参考本人的使用博客
apache-maven-3.5.4-bin.zip
apache-maven-3.5.4-bin.rar完全可以使用的工具,可以放心下载
Arthas 是 Alibaba 在 2018 年 9 月开源的 Java 诊断工具。支持 JDK6+, 采用命令行交互模式,可以方便的定位和诊断 线上程序运行问题。Arthas 官方文档十分详细,详见:https://alibaba.github.io/arthas
dcmtk-3.5.4-win32-i386,Libraries were built with /MD flag on Visual Studio 6.0 SP6.
python-3.5.4-amd64.7z环境
maven版本
maven.rar apache-maven-3.5.4
用maven,我们可以方便统一的进行jar包管理,jar包版本升级,快速项目构建以及分模块开发等相关功能。maven使用得好,项目开发速度就会成倍的提升。总之,项目越大,越能体现maven的优势。
samba-common-3.5.4-68.el6.i686.rpm
PACS开发必备,DICOM开源开发包 dcmtk-3.5.4 dcmtk-3.5.4-win32-help dcmtk-3.5.4-win32-i386 由于上传限制这是第一部门,另一部分为 dcmtk-3.5.4开发包(win32支持文件)
Maven项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的项目管理工具软件。 Maven 除了以程序构建能力为特色之外,还提供高级项目管理工具。由于 Maven 的缺省构建规则有较高的可重用性,...
apache-maven-3.5.4-bin.zip,本地maven库压缩包,具体配置流程可在我的文档中查看
samba-doc-3.5.4-68.el6
Nextcloud客户端 for Linux V3.5.4-x86_64 NextCloud官方源代码安装包+客户端合集 https://blog.csdn.net/liujinbao8000/article/details/81365937
processing-3.5.4-linux64.tgz
apache-maven-3.5.4用于管理jar包的工具,此处提供的版本为3.5.4,有需要的小伙伴可以下载,也可以去官网自行下载。
maven仓库安装包,内含apache-maven-3.5.4-bin.tar.gz的Linux安装包和apache-maven-3.5.4-bin.zip的windows安装包