JavaScript无侵入拓展组件功能
作者:
CoderYan | 来源:发表于
2017-08-10 18:40 被阅读12次
通过自定义拓展方法,可以增强js组件功能。
jQuery.fn.valid = function(_this){
return function(){
var _valid = _this.call(this);
if(!OPC.DEBUG && !_valid){
setTimeout(() => {
$(this).validate().focusInvalid();
}, 168);
//this.find("input").filter('.error:first').focus();
}
return !OPC.DEBUG ? _valid : true;
};
}(jQuery.fn.valid);
// 拓展功能
$.validator.prototype.focusInvalid = function (_this) {
return function(){
_this.call(this);
OPC.LADDA.stopAll();
};
}($.validator.prototype.focusInvalid);
本文标题:JavaScript无侵入拓展组件功能
本文链接:https://www.haomeiwen.com/subject/kffkrxtx.html
网友评论