设置值 新增当前元素派发change、blur事件
在选择的时间改变后,可以通过监听 change、blur 事件。 原来元素会触发一个 blur 事件,但是只是在弹窗出现的时候触发,选择时间后无法通过监听时间的方式获取到当前的时间。 主动派发 blur 可以配合jQuery.validate 插件验证必填(私心一下)。pull/64/head
parent
898ec1d05d
commit
4617e18613
File diff suppressed because one or more lines are too long
|
@ -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')
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue