如何在对话框显示中将回调附加到 jquery 效果? [英] How to attach callback to jquery effect on dialog show?
问题描述
我的问题是我不知道如何将回调附加到 jquery ui 对话框显示.
My problem is that I do not know how to attach callback to the jquery ui dialog show.
表演其实是一种选择:
$( ".selector" ).dialog({ show: 'slide' });
我想在幻灯片动画完成后有一个回调.我从效果本身看,它们有一个回调:
I want to have a callback after the slide animation is complete. I looked from the effects itself and they have a callback:
effect( effect, [options], [speed], [callback] )
但是在对话框中,效果的设置非常不同.我也试过放:
But in the dialog the effect is set up very differently. I tried also putting:
$( ".selector" ).dialog({ show: 'slide', callback: function() {} });
但是没有用.
建议?
推荐答案
Update 2015-07-27 对于使用 jQuery v1.10.0 或更高版本的任何人,请参阅 这个其他答案 因为我的解决方案不适用于较新版本的 jQuery.
Update 2015-07-27 For anyone using jQuery v1.10.0 or above please see this other answer as my solution will not work with newer versions of jQuery.
原答案
已经回答了,但既然我有了答案,我还是要发布它…
Already answered but since I had an answer, I'm going to post it anyway…
$('#dialog').dialog({
show: {
effect: 'slide',
complete: function() {
console.log('animation complete');
}
},
open: function(event, ui) {
console.log('open');
}
});
在控制台
这篇关于如何在对话框显示中将回调附加到 jquery 效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!