1. #1
    Sencha User
    Join Date
    Sep 2010
    Posts
    19
    Vote Rating
    2
    gr0uch0 is on a distinguished road

      0  

    Default Clicking sub-menus when JSON-loading a menu doesn't fire the click event

    Clicking sub-menus when JSON-loading a menu doesn't fire the click event


    Hi - I'm having bother getting submenu's to fire the click event. The parents fire OK and the children show up OK - it's just that the children that aren't firing the click event.

    I think it's to do with the way I'm loading the menu items, they're loaded from a JSON string using Ext.Loader which would be very cool if I can get it working. I'm just not sure how to define the submenus in either the controller or the JSON/View.

    Any help much appreciated

    Code:
    Ext.define('ARC.controller.MainController', {
        extend: 'Ext.app.Controller'
        ,init: function() {
            this.control({
                'menusidebar': {
                    click: this.onItemClick
                }
            })
        }
        
        ,onItemClick: function(menu, item, e, opts) {
            console.log('item=',item.text);
        }
    });

    Code:
    Ext.define('ARC.view.menu.SideBar', {
        alias: 'widget.menusidebar'
        ,extend: 'Ext.menu.Menu'
        ,initComponent: function() {
            Ext.apply(this, {
                id: 'sidebar'
                ,dock: 'left'
                ,border: false
                ,cls: 'sidebar-list'
                ,plain: true
                ,floating: false
                ,loader: {
                    url: 'app/php/menu/getMenu.php'
                    ,renderer: 'component'
                    ,autoLoad: true
                }
            });
            this.callParent(arguments);
        }             
    });
    Code:
    JSON STRING
    [{
        "text":"Home"
        ,"iconCls":"icon-home"
        ,"handler":"arcHome()"
        ,"cls":"product"
        ,"menu":[{
            "text":"Calendars"
            ,"iconCls":"icon-under-construction"
            ,"handler":"underConstruction()"
        },{
            "text":"Task Manager"
            ,"iconCls":"icon-under-construction"
            ,"handler":"underConstruction()"
        }]
    },{
        "text":"Admin"
        ,"iconCls":"icon-admin"
        ,"handler":""
        ,"cls":"product"
        ,"menu":[{
            "text":"Mailing"
            ,"iconCls":"icon-mailer"
            ,"handler":"arcMailer()"
        },{
            "text":"Address Book"
            ,"iconCls":"icon-address-book"
            ,"handler":"arcAddressBook()"
        },{
            "text":"H.R."
            ,"iconCls":"icon-under-construction"
            ,"handler":"underConstruction()"
        }]
    }]

  2. #2
    Sencha User juanb's Avatar
    Join Date
    Jun 2011
    Location
    usa
    Posts
    42
    Vote Rating
    1
    juanb is on a distinguished road

      0  

    Default


    why don't you use the .loading(true) before call and .loading(false) when success.?

  3. #3
    Sencha User
    Join Date
    Sep 2010
    Posts
    19
    Vote Rating
    2
    gr0uch0 is on a distinguished road

      0  

    Default


    I'm not sure I get you - do you mean that I should replace the 'click' event with a 'loaded' event?

  4. #4
    Sencha User juanb's Avatar
    Join Date
    Jun 2011
    Location
    usa
    Posts
    42
    Vote Rating
    1
    juanb is on a distinguished road

      0  

    Default


    no, the components has a propertie (loading) which if is true then lays a maks and a message over the component until you set it to false.

Thread Participants: 1