道场对话框onEnd()动画例外 [英] Dojo Dialog onEnd() animation exception

查看:135
本文介绍了道场对话框onEnd()动画例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有动画序列期间与道场的Dijit对话框一个问题.hide()方法。我使用的Dojo 1.7与腾的主题。我有一个在我的对话框,关闭对话框取消按钮。

I have a problem with the Dojo Dijit Dialog .hide() method during the animation sequence. I am using Dojo 1.7 with Tundra theme. I have a cancel button in my dialog that closes the dialog.

        var global_welcome = new Dialog({
            id: 'global_welcome',
                style: "width: 750px",
            draggable: false,

        content: '<button type="button" id="global_welcomeCancel"> Cancel </button>',
        onShow : function () {
                                on(dojo.byId('global_welcomeCancel'), "click", function (evt) {
                                    dojo.stopEvent(evt);
                                    global_welcome.hide();   
                                   });              
                                 });
        }
    });

这产生以下错误的Firebug的:

This produces the following error on Firebug:

exception in animation handler for: onEnd                  fx.js (line 152)

TypeError: this._fadeOutDeferred is undefined
this._fadeOutDeferred.callback(true);

previous回答这个错误,但与destroyRecursive,而不是隐藏表明,它已与动画完成之前被销毁对话框做。我试着用dojo.hitch()和setTimeout的,但似乎并没有工作。还令人不解的是,我第一次打开使用global_welcome.show()这个对话框(按另一个按钮调用)和preSS取消按钮,它的工作原理没有错误。第二次和之后,它会产生上面的错误消息。此外,对于道场对话框的右上角的默认的关闭按钮不会导致此错误。也许我可以只是昂秀调用的方法关闭按钮呼叫?

Previous answers to this error but with destroyRecursive instead of hide suggests it has to do with the dialog being destroyed before the animation finishes. I tried using dojo.hitch() and setTimeOut but that didn't seem to work. Also what is puzzling is that the first time I open this dialog using global_welcome.show() (called by another button), and press the cancel button, it works without error. The second time and afterwards, it produces the above error message. Additionally, the default close button for dojo dialogs on the top right corner never causes this error. Perhaps I could just have onShow call the methods that the close button calls?

有人能帮助我吗?在此先感谢!

Can someone help me out please? Thanks in advance!

推荐答案

问题是在你的昂秀方法。连线到click事件隐瞒,但从来没有断开。当你再次打开的对话​​框中,连线点击方法再次隐藏对话框。其结果是,当您尝试关闭对话框第二次皮会被调用两次。该错误被抛出的第二次调用来隐藏,因为动画已经被破坏了。

The problem is in your onShow method. You wire up to the click event to hide, but never disconnect it. When you open the dialog the again, you wire the click method to hide the dialog again. The result is that hide will be called twice when you try to close the dialog for the second time. The error gets thrown with the second call to hide because the animations have already been destroyed.

试试这个:

var signal = on(dojo.byId('global_welcomeCancel'), "click", function (evt) {
    dojo.stopEvent(evt);
    signal.remove();
    global_welcome.hide();   
}); 

这篇关于道场对话框onEnd()动画例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆