50 行
1.6 KiB
JavaScript
可执行文件
50 行
1.6 KiB
JavaScript
可执行文件
//提交时给ajaxForm方法加上loading动画,防止提交按钮重复点击,用法:$('form').loadingForm()
|
||
(function ($) {
|
||
$.fn.loadingForm = function (options) {
|
||
console.log(11111)
|
||
this.each(function () {
|
||
var el = this;
|
||
$(el).ajaxForm({
|
||
beforeSubmit: function (data) {
|
||
if (options.beforeSubmit != null) {
|
||
if (options.beforeSubmit(data)) {
|
||
layer.load();
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
layer.load();
|
||
return true;
|
||
},
|
||
success: function (data) {
|
||
layer.closeAll();
|
||
if (options.success != null) {
|
||
options.success(data);
|
||
}
|
||
}
|
||
});
|
||
});
|
||
};
|
||
})(jQuery);
|
||
//给post方法加上loading动画,防止提交按钮重复点击,用法:$.loadingPost()
|
||
(function ($) {
|
||
$.loadingPost = function (url, data, callback) {
|
||
console.log(11111)
|
||
layer.load();
|
||
if ($.isFunction(data)) {
|
||
$.post(url, function (d) {
|
||
layer.closeAll();
|
||
if (data) {
|
||
data(d);
|
||
}
|
||
});
|
||
} else {
|
||
$.post(url, data, function (d) {
|
||
layer.closeAll();
|
||
if (callback) {
|
||
callback(d);
|
||
}
|
||
});
|
||
}
|
||
};
|
||
})(jQuery); |