设置值 新增当前元素派发change、blur事件

在选择的时间改变后,可以通过监听 change、blur 事件。
原来元素会触发一个 blur 事件,但是只是在弹窗出现的时候触发,选择时间后无法通过监听时间的方式获取到当前的时间。
主动派发 blur 可以配合jQuery.validate 插件验证必填(私心一下)。
pull/64/head
凌子清 2017-09-22 11:13:06 +08:00
parent 898ec1d05d
commit 4617e18613
2 changed files with 237 additions and 223 deletions

2
dist/laydate.js vendored

File diff suppressed because one or more lines are too long

View File

@ -10,6 +10,18 @@
;!function(){ ;!function(){
"use strict"; "use strict";
function eventDispatcher(e, eventName) {
try {
var ev = document.createEvent('HTMLEvents');
ev.initEvent(eventName, true, true);
} catch (err) {}
if (e.fireEvent) {
e.fireEvent('on' + eventName);
} else {
e.dispatchEvent(ev);
}
}
var isLayui = window.layui && layui.define, ready = { var isLayui = window.layui && layui.define, ready = {
getPath: function(){ getPath: function(){
var js = document.scripts, script = js[js.length - 1], jsPath = script.src; var js = document.scripts, script = js[js.length - 1], jsPath = script.src;
@ -312,6 +324,8 @@
LAY.prototype.val = function(value){ LAY.prototype.val = function(value){
return this.each(function(index, item){ return this.each(function(index, item){
item.value = value; item.value = value;
eventDispatcher(item, 'change')
eventDispatcher(item, 'blur')
}); });
}; };