我做了一个启动画面的jQuery插件。它用了jQuery的动画功能,并通过以下initalized和触发:延迟,直到jQuery动画完成
$('#temperature_splash').splashScreen();
$('.tempGraphButton').click(function() {
$('#temperature_splash').splashScreen('splash', 300);
//Here, I would like to make an ajax request when the animation has finished
}
我想提出一个Ajax请求在插件中的动画结束后,但我不知道怎么办。有没有人有什么建议?插件代码的
大纲
$.fn.splashScreen = function (method) {
// Method calling logic
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return methods.init.apply(this, arguments);
} else {
$.error('Method ' + method + ' does not exist');
}
}
var methods = {
init: function() {
//Some initializations
},
splash: function (time) {
//Setting some properties
splashScreenContent.animate({
width: width,
left: leftPos
}, time).animate({
height: height,
top: topPos
}, time);
return false;
}
}
})(jQuery);
完美里面的代码之前执行。现在它可以工作。 – olif 2012-08-03 18:36:49