1. #1
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    4,893
    Vote Rating
    176
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default Floating menu with toggle buttons - toggle prior to render

    Floating menu with toggle buttons - toggle prior to render


    I have a panel with three menus set to floating: false. These menus are populated with toggle buttons. When I collapse that panel I have a vertical toolbar that shows up in its place with buttons with menu configs using the same menu xtypes we were in the collapsible panel.

    What I'm hoping to do is keep the menus sync'd so that when I press a toggle button on one the other is toggled. This works great if I've clicked on the button owning the floating menu so that is instantiated and shown.

    It does not work prior to me manually clicking on and showing each floating menu's owning button since when I attempt to toggle(true, true) on the button on the hidden menu there is apparently nothing yet in existence to toggle (though ComponentQuery find the menu/toggle button).

    Any suggestions as to how I can allow the yet hidden menu/toggle buttons to be toggled at the time the application is loaded would be much appreciated.

    *I tried to at application load time find all menus that are floating: true and show().hide() them and that did not work.

    *I believe I can set autoShow to true and have a listener set to single that hides the menu on its first show event, but I haven't actually tested that, yet - hoping for a more elegant solution.

  2. #2
    Sencha User mberrie's Avatar
    Join Date
    Feb 2011
    Location
    Bangkok, Thailand
    Posts
    506
    Vote Rating
    14
    mberrie will become famous soon enough mberrie will become famous soon enough

      0  

    Default


    If you call toggle() on the unrendered button, do you get an error message in the console?

    Ext UI components usually support setting/changing the value even if the component has not been rendered yet. This should be the same for the Button class.

    looking at the source code (4.0.2a) you can see that the rendered state is being considered. UI changes are not being triggered (line 5+6), but the pressed state will be stored (line 9) even if the component has no been rendered yet.
    However, I suspect a bug in the 2nd highlighted line (line 8).

    As I see it btnEl is only available AFTER the component has been rendered. Hence you should see a Javascript error in the debugger console.

    Code:
    toggle: function(state, suppressEvent) {
        var me = this;
        state = state === undefined ? !me.pressed: !!state;
        if (state !== me.pressed) {
            if (me.rendered) {
                me[state ? 'addClsWithUI': 'removeClsWithUI'](me.pressedCls);
            }
            me.btnEl.dom.setAttribute('aria-pressed', state); // me.btnEl is undefined if (!me.rendered)
            me.pressed = state;
            if (!suppressEvent) {
                me.fireEvent('toggle', me, state);
                Ext.callback(me.toggleHandler, me.scope || me, [me, state]);
            }
        }
        return me;
    },


    See if moving the line inside the me.rendered block works for you.

    If so, you can wrap the code change in an override and file a bug.

  3. #3
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    4,893
    Vote Rating
    176
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default


    Exactly right. I get:
    me.btnEl is undefined
    - me.btnEl.dom.setAttribute('aria-pressed', state);

    Didn't know if this would be a bug or expected by design.

    What is the best way to communicate a bug/enhancement request?

  4. #4
    Sencha User mberrie's Avatar
    Join Date
    Feb 2011
    Location
    Bangkok, Thailand
    Posts
    506
    Vote Rating
    14
    mberrie will become famous soon enough mberrie will become famous soon enough

      0  

    Default


    Use this template to post in the Ext:Bugs sub-forum.

Thread Participants: 1

Tags for this Thread