如何从视图子关闭视图父级?

时间:2017-10-22 16:36:57

标签: javascript extjs6-classic

我使用了ext framework 6.2.0中的模板admin-dashbord。

当我使用它时,在我的AuthenticationController中

this.getView().destroy();

只有子视图登录关闭。不是父级。

app-main组件是在父视图后面构建的。

我不知道如何关闭父视图。

我有以下结构:

LoginWindow.js

Ext.define('Admin.view.authentication.LockingWindow', {
    extend: 'Ext.window.Window',
    xtype: 'lockingwindow',

    requires: [
       'Admin.view.authentication.AuthenticationController',
       'Ext.layout.container.VBox'
    ],

    cls: 'auth-locked-window',
    closable: false,
    resizable: false,
    autoShow: true,
    titleAlign: 'center',
    maximized: true,
    modal: true,

    ....

});

Login.js

Ext.define('Admin.view.authentication.Login', {
    extend: 'Admin.view.authentication.LockingWindow',
    xtype: 'login',

    requires: [
        'Admin.view.authentication.Dialog',
        'Ext.container.Container',
        'Ext.form.field.Text',
        'Ext.form.field.Checkbox',
        'Ext.button.Button'
    ],

    title: 'Let\'s Log In',
    defaultFocus: 'authdialog', // Focus the Auth Form to force field focus as well
 ....

           {
                xtype: 'button',
                reference: 'loginButton',
                scale: 'large',
                ui: 'soft-green',
                iconAlign: 'right',
                iconCls: 'x-fa fa-angle-right',
                text: 'Login',
                formBind: true,
                listeners: {
                    click: 'onLoginButton'
                }
            },

});

AuthenticationController.js

Ext.define('Admin.view.authentication.AuthenticationController', {
   extend: 'Ext.app.ViewController',
   alias: 'controller.authentication',

   onLoginButton: function() {

       var me = this;

        localStorage.setItem("TutorialLoggedIn", true);

        // Remove Login Window

        this.getView().destroy();

        // Add the main view to the viewport
            var main  = Ext.create({
            xtype: 'app-main'
        });

        me.redirectTo('dashboard', true);
    },

});

1 个答案:

答案 0 :(得分:0)

  1. 获取视图:登录
  2. 获取父级:LockingWindow
  3. 销毁父级:LockingWindow
  4. 这是我的方法添加到AuthenticationController.js并在onLoginButton()方法中调用。

    createInterface : function(){
    
            var me = this,
                view = me.getView(),
                window = view.up('window');
    
            Ext.create({
                xtype: 'app-main'
            });
            window.destroy();
    
            me.redirectTo('dashboard', true);
     }
    
相关问题