beforeTabChange事件暂停并继续(无限循环)

时间:2015-09-28 00:41:35

标签: javascript extjs coffeescript infinite-loop messagebox

我有标签,我希望在标签更改之前进行某种验证,以保存某人的工作。

实际发生的事情是标签只是直接通过我的代码,然后在回调标签更改后打开消息框。这是因为Extjs提供的异步消息框。我仍然无法找到可行的解决方案。任何帮助都会得到极大的赞赏。

此外,代码也是用咖啡脚本编写的。我编辑了帖子,我的代码现在陷入无限循环。

这就是我现在所拥有的。

             beforetabchange:
                single:true
                fn:(tabPanel, newTab, oldTab, eOpts)->
                    if oldTab.isModified && oldTab.itemId != "linkedItemsTab" && oldTab.itemId != "capacityTab" && oldTab.itemId != "capacityTabEnterprise"
                        Ext.Msg.show
                            title: 'Warning'
                            message: 'You have unsaved changes in the <b>' + oldTab.title + '</b> tab, would you like to save them?'
                            buttons: Ext.Msg.YESNOCANCEL
                            icon: Ext.Msg.QUESTION
                            fn: (btn) ->
                                if (btn == 'yes')
                                    tabPanel.suspendEvents()
                                    oldTab.saveRelease (release, isChanged) ->
                                    highlight "Your changes have been saved"
                                    oldTab.isModified = false
                                tabPanel.setActiveTab(newTab)
                                tabPanel.resumeEvents()
                        return false;
                    else if oldTab.isModified && (oldTab.itemId == "capacityTab" or oldTab.itemId == "capacityTabEnterprise")
                        Ext.Msg.show
                            title: 'Warning'
                            message: 'You have unsaved changes in the <b>' + oldTab.title + '</b> tab, would you like to save them?'
                            buttons: Ext.Msg.YESNOCANCEL
                            icon: Ext.Msg.QUESTION
                            fn: (btn) ->
                                if (btn == 'yes')
                                    tabPanel.suspendEvents()
                                    me.saveActiveTabChanges()
                                    highlight "Your changes have been saved"
                                    oldTab.isModified = false
                                tabPanel.setActiveTab(newTab)
                                tabPanel.resumeEvents()
                        return false;
                    return true;

0 个答案:

没有答案
相关问题