如何将回调附加到对话框显示的 jquery 效果?
我的问题是我不知道如何将回调附加到 jquery ui 对话框显示。
显示实际上是一个选项:
$( ".selector" ).dialog({ show: 'slide' });
我想在幻灯片动画完成后进行回调。我从效果本身来看,它们有一个回调:
effect( effect, [options], [speed], [callback] )
但在对话框中,效果的设置非常不同。我也尝试过输入:
$( ".selector" ).dialog({ show: 'slide', callback: function() {} });
但没有成功。
建议?
My problem is that I do not know how to attach callback to the jquery ui dialog show.
The show is actually an option:
$( ".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() {} });
But it didn't work.
Suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我发现有必要使用“focus:”事件。由于显示:我失去了正确选择的按钮。可爱的互动。
I found it necessary to use the "focus:" event. I was losing the correctly selected button because of the show:. Lovely interactions.
更新 2015-07-27 对于使用 jQuery v1.10.0 或更高版本的任何人,请参阅这个其他答案 因为我的解决方案不适用于较新版本的 jQuery。
原始答案
已经回答了,但既然我有了答案,我还是要发布它......
在<中显示
open
,然后是animationcomplete
em>控制台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.
Original answer
Already answered but since I had an answer, I'm going to post it anyway…
Shows
open
followed byanimation complete
in the Console两年后,建议的解决方案(由 @andyb)不再适用于当前版本的 jQuery UI(特别是从 v1.10.0 开始)。他的解决方案依赖于
complete
回调方法——一个未记录的功能。我想出了一个最新的解决方案,使用 jQuery
Promise
对象:这是常见的 JSFiddle 演示:http://jsfiddle.net/losnir/jcmpm/
Two years later, the suggested solution (by @andyb) is no longer working in current versions of jQuery UI (specifically since v1.10.0). His solution relied on the
complete
callback method - an undocumented feature .I've came up with an up-to-date solution, using jQuery
Promise
object:Here is the usual JSFiddle Demo: http://jsfiddle.net/losnir/jcmpm/
我下载了 jquery ui dev 包,发现回调设置为“完整”:
感谢每个试图帮助解决此问题的人:)
I downloaded the jquery ui dev bundle and found out that the callback is set with "complete":
Thanks for everyone trying to help solve this :)
尝试使用对话框的
open
事件:Try to use
open
event of dialog: