【问题标题】:Uncaught ReferenceError: connectWin is not defined ! SenchaTouch未捕获的 ReferenceError:connectWin 未定义!煎茶触摸
【发布时间】:2014-03-27 09:57:00
【问题描述】:

以下问题: 我得到了viewClass“connectWin”和controllerClass“connectWinController”。 整个程序从“connectWin”视图开始,所以如果点击“开始”按钮, connectWinController 应该隐藏“connectWin”,做一些事情并打开另一个视图 “订单视图”。但是,如果我点击“开始”按钮,我的控制台上会出现错误。

代码如下:

app.js:

Ext.Loader.setConfig({

});


Ext.application({

    name: 'SenchaDiagApp',



    requires: [
        'Ext.MessageBox',
        'Ext.field.Select',
        'Ext.form.FieldSet',
        'Ext.form.Panel',
        'Ext.Img'
    ],

    refs: {

        connectWin: 'connectWin'
    },  

    launch: function() {
        console.log("App launch!!"); 



         connectWin= {

            layout: 'fit',
                items: [{

                    xtype : 'connectWin'
                }],
            }; 
        Ext.Viewport.add(connectWin);   

    }

});

connectWin

Ext.define('AM.view.connectWin' , {

    extend: 'Ext.Panel',  
    alias : 'widget.connectWin', 


    config:{
        ui : 'light',
        items: [
            {

                 xtype:         'panel',       
                 scrollable:    false,
                 centered:      true,
                 modal:         true,
                 width:         '100%',
                 height:        '50%', 

                    items: [ 

                        {

            xtype:      'titlebar',
                        docked:     'top',
                        height:     '110px',
                id:         'connectTitleID',
                        title:      'Login'
                    },

                {
                        xtype:       'spacer'
                    },




                {
                        xtype:      'titlebar', // 2 Titlebar unten 
                        docked:     'bottom',
                        height:     '110px',

                              items:[                       

                               {   
                                     xtype:     'button',
                                     align:     'left',
                     height:    '100px',
                     width: '200px',
                                     action:     'bestellen',
                     text:      'Start',
                                   }],


            }],              
        },
    }); 

connectWinController:

Ext.define('AM.controller.connectWinController', {

    extend: 'Ext.app.Controller',

    config:{


                refs: {

                connectWin: 'connectWin'

                                 }
            },

    init: function() {

    this.control(
          'connectWin button[action=bestellen]':{

           tap: this.verbindungBestellung 

        },
    },


          verbindungBestellung : function(){
                            console.log("Start");
                connectWin.hide()  **//Now it says: connectWin is not defined?**


                             var orderView = Ext.create('AM.view.orderView');
                             Ext.Viewport.add(orderView);
                    }


        });
                                    '

【问题讨论】:

    标签: sencha-touch undefined-reference referenceerror


    【解决方案1】:

    在控制器中,获取您的视图的参考,

    参考:{

    connectWin: { autoCreate:true,selector:'#connectWin',xtype:'connectWin' },

    }

    使用 xtype:'connectWin' 代替别名...

    【讨论】:

      【解决方案2】:

      app.js 中声明每个视图、控制器、模型、存储您在应用程序中使用的任何内容:

      Ext.application({       
          name: 'AppName',
          requires: [],
          models:['Model-1','Model-2'],
          controllers : ['Main'],
          views : ['View-1','View-2'],
          stores : [ 'Store-1' , 'Store-2'],
      
          launch : function() {
              Ext.fly('appLoadingIndicator').destroy();
              Ext.Viewport.add({
                  xclass: 'AppName.view.View-1',
                  autoDestroy: false,
                  showAnimation:false
              });
      
          }
      });
      

      【讨论】:

        猜你喜欢
        • 2023-03-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-12-25
        • 2012-11-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多