Results 1 to 8 of 8

Thread: 5.0.1 use viewcontroller scope in listener instead of component like the api doc

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-15463 in 5.1.0.107.
  1. #1
    Sencha Premium User SebTardif's Avatar
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    1,294

    Default 5.0.1 use viewcontroller scope in listener instead of component like the api doc

    We had a regression when we moved to Ext JS 5.0.1. Old listener are receiving for scope the viewcontroller instead of the component. In particular, with menu.

    2 different developers in two different projects were hit by this.

    I looked at the documentation and it's still saying that I should receive the component, and in any case, it's kind of breaking backward compatibility.

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

    Default

    Thanks for the report. Can you please post a test case which exhibits the issue you are facing?
    https://fiddle.sencha.com/#home

  3. #3
    Sencha User Phil Guerrant's Avatar
    Join Date
    May 2011
    Location
    Colorado
    Posts
    352

    Default

    Without a test case it's hard to say for sure what your issue is, but you may need to set
    Code:
    defaultListenerScope: true
    on your component if you want listeners to resolve to that component instead of to a ViewController further up the hierarchy.

    More in depth description of how scope resolution works was discussed in a recent blog post: http://www.sencha.com/blog/declarati...s-in-ext-js-5/
    Phil Guerrant
    Ext JS - Development Team

  4. #4
    Sencha Premium User SebTardif's Avatar
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    1,294

    Default

    Quote Originally Posted by Phil Guerrant View Post
    you may need to set
    Code:
    defaultListenerScope: true
    on your component if you want listeners to resolve to that component instead of to a ViewController further up the hierarchy.
    Your workaround is working. However, my understanding is that it should not be needed. The code below receiving bad scope in afterrender is not using listener name but a direct function.

    Code:
    Ext.define('MyApp.view.Base.BaseGrid', {
        extend: 'Ext.grid.Panel',
        columnLines: true,
        config: {
            showToolbarOptions: {
                refresh: true,
                exportBut: true,
                views: true,
                quickFilter: true,
                search: true
            },
            currentViewLabel: 'My View',
            userViews: [],
            systemViews: []
        },
        listeners: {
            afterrender: function () {
                var me = this; //***** this is the controller!!!
                var menu = me.buildMenu(),
                    toolbar = me.getToolbar();
                if (toolbar) {
                    me.addDocked(toolbar);
                }
                if (menu) {
                    // have to add as a child to this grid view to use the same controller
                    me.add(menu);
                }
            }

  5. #5
    Sencha User Phil Guerrant's Avatar
    Join Date
    May 2011
    Location
    Colorado
    Posts
    352

    Default

    I see your point. It would be more intuitive to use the component instance as the scope if you've given us an inline function instead of a method name. I'll see what it takes to get this fixed in a future release.

    Another possible workaround is to use scope:'this'. The scope resolution mechanism will resolve the string "this" to the component instance
    Phil Guerrant
    Ext JS - Development Team

  6. #6
    Sencha Premium User SebTardif's Avatar
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    1,294

    Default

    Thanks for your consideration. Just to make sure it is clear, that behavior changed from 5.0.0 to 5.0.1 without any documentation changes. Also, each time I read the documentation my understanding is that 5.0.0 behavior is what is expected.

    I think we need some kind of action item and so a bug, feature request, or documentation update should be assigned to this forum thread.

  7. #7
    Sencha User Phil Guerrant's Avatar
    Join Date
    May 2011
    Location
    Colorado
    Posts
    352

    Default

    @SebTardif I'm trying to create a simple test case so I can make sure we have the correct behavior in future releases. I've created the following fiddle, but it doesn't seem to fail as you are describing:

    https://fiddle.sencha.com/#fiddle/duc

    Are you able to narrow your problem down to a small test case?

    Any chance you are using scope:'controller' anywhere in your code?
    Phil Guerrant
    Ext JS - Development Team

  8. #8
    Sencha Premium User SebTardif's Avatar
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    1,294

    Default

    I was originally not able to create a Fiddle about it but happened on two different apps, and reproducible always.

    I think the problem is gone, and this bug sound like it -> EXTJS-14701 Listeners declared on class have an incorrect default scope when passing a function reference

    Also, I just tried to figure out again when it started to work but many nightly build have been removed from fiddle.sencha.com.

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
  •