Results 1 to 2 of 2

Thread: Window with VC not finding reference on show - fiddle

  1. #1
    Sencha User
    Join Date
    May 2011
    Posts
    26
    Answers
    1

    Default Window with VC not finding reference on show - fiddle

    Hi folks - I'm slightly baffled that a simple Window cannot resolve its VC on 'show' event. The attached fiddle will work - it has a window with VC. Click the button to see the VC correctly resolved.

    If you un-comment the 'show' event however, the code will fail in the console because the function can't be found. Lots of my code works like this already, am I doing something stupid?

    I've tried using add() instead of widget() in case it's some kind of MVC nesting issue but Ext just seeks the function in the wrong VC - the top-level VC applied to the viewport.

    Any help very much appreciated. Thx

    https://fiddle.sencha.com/#view/editor&fiddle/1kvd

    Code:
    Ext.define('Admin.view.window.MyWindowController', {
        extend : 'Ext.app.ViewController',
        alias  : 'controller.mywindow',
    
    
        doShowStuff : function() {
            Ext.Msg.alert('SHOW STUFF!');
        },
    
    
        doOkStuff : function() {
            Ext.Msg.alert('OK STUFF!');
        }
    });
    
    
    Ext.define('Admin.view.window.MyWindow', {
        extend     : 'Ext.window.Window',
        alias      : 'widget.mywindow',
        autoShow   : true,
        controller : 'mywindow',
        width      : 200,
        height     : 200,
        html       : 'I am your window',
    
    
        buttons : [
            { text : 'OK', handler : 'doOkStuff', scope : 'controller' }
        ],
    
    
        listeners : [
        //    { show : 'doShowStuff', scope : 'controller' },
        ]
    });
    
    
    Ext.widget('mywindow');

  2. #2
    chramer's Avatar
    Join Date
    Feb 2011
    Location
    Chisinau, Moldova
    Posts
    316
    Answers
    64

    Default

    The "listeners" config is an object, you've specified it as an array. So this is the right way to do it for your case:
    Code:
    listeners: {
      show: 'doShowStuff',
    }
    You don't have to specify the scope in this case. It will resolve to the view controller.

Similar Threads

  1. Ext.Loader not finding defined classes in sencha fiddle
    By dkingofpa in forum Sencha Fiddle
    Replies: 4
    Last Post: 23 Mar 2015, 4:27 AM
  2. Fiddle does not show fiddles saved by the user
    By mx_starter in forum Sencha Fiddle
    Replies: 3
    Last Post: 4 Dec 2013, 8:04 AM
  3. Finding the right window to adjust
    By chrizmaster in forum Ext 3.x: Help & Discussion
    Replies: 10
    Last Post: 29 Jul 2010, 6:20 AM

Posting Permissions

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