How do I resolve the issue of the browser being Asynchroom and each new event will be add to the event stack. In my previous question I got suggested to wait till the full component is loaded because of caching. Also this answer was giving to Robert in another topic, see below.

 - http://tridion.stackexchange.com/questions/2695/how-do-i-check-if-a-component-is-the-parent-or-a-copy-of-the-parent-using-the-tr
 - http://tridion.stackexchange.com/questions/2368/how-to-use-tridion-javascript-framework-anguilla-to-get-the-workflowinfo-for-a

My current code looks like this now; 

<!-- language: lang-js -->

    /// <summary>
    ///
    /// </summary>
    /// <returns>boolean</returns>
    Extensions.Unlocalize.prototype.isEnabled = function Unlocalize$isEnabled(selection) {
        var item = $models.getItem(selection.getItem(0)),
            itemTCM = item.getId(),
            pubTCM = null,
            isAvailable = false,
            itemRegex = /.?tcm:(.*?)\-/,
            pubRegex = /.*?\-(.*)-.*/;

        console.log("Extensions.Unlocalize.prototype.isEnabled; Started."); 
        console.log("Info of parameter item at start: ", item.getInfo());     

        //Make sure the component is loaded before using getOwningPublicationId();
        var onItemLoaded = function Extensions$Unlocalize$_onItemLoaded() {
            console.log("Extensions$Unlocalize$_isEnabled; Started."); 
            $evt.removeEventHandler(item, "load", onItemLoaded);
          
            var itemInfo = item.getInfo();
            console.log("Info of parameter item in eventHandler: ", itemInfo);
        
            pubTCM = item.getOwningPublicationId(); 
            pubTCM = pubTCM.match(pubRegex);
            itemTCM = itemTCM.match(itemRegex);
        
            if (itemTCM[1] == pubTCM[1]) {
                isAvailable = true;
            }        
            console.log("Extensions$Unlocalize$_isEnabled; ", isAvailable);         
        };
    
        console.log("Extensions.Unlocalize.prototype.isEnabled; addEventHandler"); 
        $evt.addEventHandler(item, "load", onItemLoaded);
    
        console.log("Extensions.Unlocalize.prototype.isEnabled; item.load()"); 
        item.load(item.isLoaded(true), $const.OpenMode.VIEW);

        console.log("Extensions.Unlocalize.prototype.isEnabled; Return."); 
        return isAvailable;
    }
    
This works all good, the only issue is that isEnabled function is finished before _onItemLoad is done, this way return isAvailable is always false. Where I would like to check if the component is in the same publication created as being selected.

The outcome of the console looks like this:

    Extensions.Unlocalize.prototype.isEnabled; Started. 
    Info of parameter item at start: Tridion.ContentManager.ItemInfo {ID: "tcm:24-88", Title: undefined, Icon: "T16L0P0", ItemType: "tcm:16", ItemTypeName: "Component"…}
    Extensions.Unlocalize.prototype.isEnabled; addEventHandler 
    Extensions.Unlocalize.prototype.isEnabled; item.load() 
    Extensions.Unlocalize.prototype.isEnabled; Return. 
    Extensions$Unlocalize$_isEnabled; Started.
    Info of parameter item in eventHandler: Tridion.ContentManager.ItemInfo {ID: "tcm:24-88", Title: "Pie dessert wypas", Icon: "T16L0P0", ItemType: "tcm:16", ItemTypeName: "Component"…}
    Extensions$Unlocalize$_isEnabled;  false 

This is of a component that is not selected in the publication it was created. If I select a component that is created in this publication the last log will be true.

How do I resolve the issue that the item is always disabled(false) in my menu.