所以我已经构建了一个自定义对话框JQuery插件,但是我遇到了回调函数的问题。 我试图在对话框关闭后重新加载页面,但我的问题是页面重新加载很快,所以我只看到对话分秒,当它实际上应该显示5秒后逐渐消失。 我有什么想法我做错了吗?我希望在页面重新加载之前消息淡出。
以下是我对该插件的调用:
$('.messages').myPlugin({
'message' : 'Testing'
},function(){location.reload()})
这是插件脚本:
(function( $ ){
$.fn.myPlugin = function( options, callback ) {
if (typeof callback == 'function') { // make sure the callback is a function
callback.call(this); // brings the scope to the callback
}
var settings = {
//DEFAULT OPTIONS
...OPTIONS IN HERE....
};
if ( options ) {
$.extend(settings, options);
};
return this.each(function() {
.....BUILD THE DIALOG....
});
return this;//Leave this to allow chaining
};
}) (jQuery);