Search code examples
javascriptextjsextjs4extjs4.2

ExtJS 4 - Getting the Selected item of a Menu


I am building a web application where the user can select choices off of a menu. So far, I've been handling the menu item selection quite well. I can assign a selection listener to my menu item and do actions accordingly.

However, before I can do anything based off of the selection, I have to make the user log in first. The flow would be as such:

Menu Item Selection --> Log In --> Action based off of the menu selection

My main issue now is I can't seem to get the selected item from the menu. I've checked the Sencha Docs for this and the Menu doesn't seem to have a getSelection() method in it. I need to be able to fetch the selected item in my menu.

Does anyone know a work around for this scenario?


Solution

  • I actually just used Cookies to store the selected item.

    During my onClick function, I did the following:

    Ext.util.Cookies.set("key", value);
    

    and then to fetch it later on I used

    var key = Ext.util.Cookies.get("key");
    

    This works for ExtJS 4.2, as for ExtJS 5 onwards, I think using Ext.data.Session might be more desirable.