【问题标题】:How to get previous page reference/alias in extjs4如何在 extjs4 中获取上一页参考/别名
【发布时间】:2013-05-06 09:24:46
【问题描述】:

我在 extjs4 MVC 中工作。在这里我卡在我想要显示页面的位置,假设有链接。点击第一个视图的链接后,我将重定向到另一个视图.我的要求是当我要单击第二个视图按钮时,我想获得第一个视图或别名的参考或别名。

这里是查看代码:-
1) 第一个视图:--

Ext.define('App.view.left.WordOfTheDay',    {
    extend:'Ext.panel.Panel',
    alias:'widget.WordOfTheDay',
    localized:true,

    xMore:"more",
    xTitle:"Word Of The Day",
    initComponent: function () {
        Ext.apply(this, {
            title:this.xTitle,

            items:[
                   {
                     xtype:'panel',
                     html:'<br>sdf<br>sdfsdf<br>sdsddf<br><a href="#" id="wordOfDay">'+this.xMore+'</a>',
                   }]
        });
        this.callParent();
    }
});// End of login class

及其设计 2)第二视图设计:-

单击第一个视图后,它显示第二个视图。当我单击第二个视图键登录按钮时,我想获取第一个视图的引用或第一个视图的别名.. 我正在研究它,但我没有得到解决方案。请给我一些指导方针。

【问题讨论】:

    标签: extjs4 extjs4.1 extjs-mvc extjs4.2


    【解决方案1】:

    一种可能的解决方案是为每个视图分配一个唯一的 id,然后使用Ext.ComponentManager.get('view-id') 获取引用。例如:

    Ext.define('MyPanel1', {
      extend: 'Ext.Component',
      xtype: 'mypanel1',
    
      id: 'my-panel-1',
      html: 'Panel 1 <a href="#">Go</a>',
    
      initComponent: function() {
        this.on('afterrender', function() {
          this.getEl().down('a').on('click', function() {
            Ext.ComponentManager.get('my-panel-2').show(); // go to second view
            this.hide();
          }, this);
        }, this);
      }
    });
    
    Ext.define('MyPanel2', {
      extend: 'Ext.Component',
      xtype: 'mypanel2',
    
      id: 'my-panel-2',
      html: 'Panel 2 <a href="#">Back</a>',
    
      initComponent: function() {
        this.on('afterrender', function() {
          this.getEl().down('a').on('click', function() {
            Ext.ComponentManager.get('my-panel-1').show(); // back to first view
            this.hide();
          }, this);
        }, this);
      }
    });
    
    Ext.onReady(function() {
      Ext.create('Ext.container.Container', {
        items: [
          {
            xtype: 'mypanel1',
          },
          {
            xtype: 'mypanel2',
            hidden: true,
          }
        ],
        renderTo: Ext.getBody()
      });
    });
    

    Try it 在 Plunker 上

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-09
      • 2022-07-01
      • 1970-01-01
      • 2014-05-12
      相关资源
      最近更新 更多