Results 1 to 2 of 2

Thread: "view is not defined" error when trying to push a second view within a NavigationView

  1. #1
    Sencha User
    Join Date
    Apr 2015
    Posts
    10

    Default "view is not defined" error when trying to push a second view within a NavigationView

    Hi all!! I'm new to Sencha and this is my first attempt in building an app using Sencha Touch. I'm trying to use the NavigationView and getting a "view is not defined" error in the browser's JS console when I try to push a second view form the first one. I've generated the app using Sencha CMD. I've watched some videos and went over the documentation... I'm not sure where the code is wrong.


    This is the relevant part from app.js:


    Code:
    	
    Ext.application({
        name: 'Myapp',
    
    
        requires: [
            'Ext.MessageBox',
            'Ext.NavigationView'
        ],
    
    
        views: [
            'Main',
            'SecondView'
        ],
    
    
        launch: function () {
            // Destroy the #appLoadingIndicator element
            Ext.fly('appLoadingIndicator').destroy();
    
    
            // Initialize the main view
            Ext.Viewport.add(Ext.create('Myapp.view.Main'));
        },
    This is my main.js:
    Code:
    	
    Ext.define('Myapp.view.Main', {
        extend: 'Ext.NavigationView',
        xtype: 'main',
            requires: [
            'Myapp.view.SecondView'
        ],
        config: {
            fullscreen: true,
            tabBarPosition: 'bottom',
            items: [{
            title: 'mainv view',
            items: [{
                xtype: 'button',
                text: 'Go to second view',
                handler: function() {
                    // use the push() method to push another view. It works much like
                    // add() or setActiveItem(). it accepts a view instance, or you can give it
                    // a view config.
                    view.push(SecondView);
                    }
            }]
            }
          ]
        }
    });
    And this is the SecondView.js:
    Code:
    	
    Ext.define('Myapp.view.ListarTicketsView', {
        extend: 'Ext.NavigationView',
        xtype: 'SecondView',
        config: {
            fullscreen: true,
            tabBarPosition: 'bottom',
            items: [{
            title: 'second view',
            items: [{
                xtype: 'button',
                text: 'another button',
                handler: function() {
                    }
            }]
            }
          ]
        }
    });

    Any help is greatly appreciated

  2. #2
    Sencha User
    Join Date
    Apr 2015
    Posts
    10

    Default

    To Answer my own question it seems like I needed a controller to push the new view. The first video helped me: https://bitbucket.org/rohitghatol/sencha-touch2-getting-started is the controller code:
    Code:
    Ext.define('myapp.controller.myController', {    extend: 'Ext.app.Controller',    config: {        refs: {            Main: 'Main'        },        control: {            'Main button': {                release: function () {                    console.log("Button tapped");                    var MyView = Ext.create('myapp.view.MyView');                    this.getMain().push(MyView);                }            }        }    }});

Similar Threads

  1. Ext.view.View error "no method addBodyCls"
    By amsoft2001 in forum Ext: Q&A
    Replies: 2
    Last Post: 14 Jan 2014, 8:32 AM
  2. Button to push a new view in a navigationBar of a navigationView
    By benoit33 in forum Sencha Touch 2.x: Q&A
    Replies: 1
    Last Post: 2 Aug 2012, 2:38 AM
  3. Push view to navigationview using controller in SA2
    By thehyperadvisor in forum Sencha Architect 2.x: Help & Discussions
    Replies: 2
    Last Post: 17 May 2012, 8:09 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •