Alpha Video Training
Results 1 to 5 of 5

Thread: getMenu method is not a function Error - Menus Action Js - Overlapping Menus on MouseOver - Browser Navigation Menu

  1. #1
    Member
    Real Name
    Maroine A.
    Join Date
    Apr 2010
    Location
    Rabat, Morocco
    Posts
    122

    Default getMenu method is not a function Error - Menus Action Js - Overlapping Menus on MouseOver - Browser Navigation Menu

    Goal: To build a versatile browser navigation menu system using the menus action javascripting.
    Catch: Overlapping menu windows on mouseover when moving mouse pointer from one menu button to the next.

    Have a look at this short video to have an idea about the Menus action javascript: https://www.ajaxvideotutorials.com/V...ui_menus_1.swf
    It is also the first search result when you search for "menus" in the video library entitled: "Menus - Displaying pop up menus when the user clicks a button"
    I tried to prevent this overlapping using two solution attempts:
    1st Solution Attempt:
    I inspected the element that holds the div displaying the dropdown menu in order to find the id and then use document.getElementById to hide it. It worked sometimes at least. The problem with that is that the div id changes depending on whose menu button I mouseover first. Check out the following screenshots:

    Products Menu mouse over it FIRST:
    PROODUCTS_MENU_DIV_ID_SELECTED_1ST.png
    Products Menu mouse over it LAST:
    PROODUCTS_MENU_DIV_ID_SELECTED_LAST.png
    So when I put the following inline-js on mouseover of the HOME Menu Button
    Code:
    document.getElementById("A5menu0.MENU").style.display = "none";
    document.getElementById("A5menu1.MENU").style.display = "none";
    document.getElementById("A5menu2.MENU").style.display = "none";
    document.getElementById("A5menu3.MENU").style.display = "none";
    document.getElementById("A5menu4.MENU").style.display = "none";
    document.getElementById("A5menu5.MENU").style.display = "none";
    It works but then I want to hide the other dropdown menus when one menu is mouseover for example, I put this inline js code in the mouseover of the ProductsMenu:
    Code:
    document.getElementById("A5menu1.MENU").style.display = "none";
    document.getElementById("A5menu2.MENU").style.display = "none";
    document.getElementById("A5menu3.MENU").style.display = "none";
    document.getElementById("A5menu4.MENU").style.display = "none";
    document.getElementById("A5menu5.MENU").style.display = "none";
    without hiding the div of the products menu assuming that its id A5menu0.MENU won't change (which it does). this works if I mouseover the products menu first but it doesn't if i refresh the page and then mouse over other menu buttons with ids that change depending on which menu has been mouseovered first.

    2nd Solution Attempt:
    I tried to get a pointer to the menu object and execute the hide method to hide it
    getMenu method - Menus AJS - UX.png
    When I copy the example code to clipboard I get this call method of the window which is not the getMenu() method (possible BUG)
    Code:
    //call a method of the window
    var wObj = {Grid.Object}.getWindow('{Alias}MYWINDOW');
    wObj.hide();    
    //(UX Component only) Shortcut method to close a window
    {dialog.Object}.closeWindow('MYWINDOW');
    Then when I try to use getMenu method, I get the TypeError .getMenu is not a function as if the function is not defined in dialog component.
    Uncaught TypeError - getMenu is not a function on mouseover.png
    I have attached a sample testing UX named "Navigation_Menu_test" that has the dropdown menus for testing purposes.
    I am using the latest production AA v12 build (4770) and testing in the browser.

    Thanks in advance for taking the time looking into this. I do appreciate it ^^
    Maroine
    Navigation_Menu_Test.a5wcmp

  2. #2
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,814

    Default Re: getMenu method is not a function Error - Menus Action Js - Overlapping Menus on MouseOver - Browser Navigation Menu

    Is this what you're looking for?

    http://youtu.be/Uvtyhv3mYBg?hd=1

  3. #3
    Member
    Real Name
    Maroine A.
    Join Date
    Apr 2010
    Location
    Rabat, Morocco
    Posts
    122

    Default Re: getMenu method is not a function Error - Menus Action Js - Overlapping Menus on MouseOver - Browser Navigation Menu

    Yes David, that's exactly what I am looking for.

    How did you do it? Please advise.

  4. #4
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,814

    Default Re: getMenu method is not a function Error - Menus Action Js - Overlapping Menus on MouseOver - Browser Navigation Menu

    For each button... in your onMouseOver event... add an Inline-Javascript action... before the Menu action. Each Inline-Javascript action will be the same...

    Code:
    closeMenus(this);
    In the case of the Home and Logout buttons... you'll have just the Inline-Javascript action.

    The closeMenus() function will be...

    Code:
    function closeMenus(currMenuObj){
    
    if(typeof currMenuObj == 'undefined'){
    	var currMenu = 'HomeLogout';
    }else{
    	var currMenu = currMenuObj.innerHTML.toUpperCase() + "MENU";
    }
    
    	if(typeof {dialog.Object}._menus != 'undefined'){
    		var menuSel = [];
    		var menuObj = {dialog.Object}._menus;
    		for(var menuNames in menuObj){
    			menuSel.push(menuNames);
    		}
    		
    		for(i=0;i<menuSel.length;i++){
    			if(menuSel[i] != currMenu){
    				{dialog.object}._menus[menuSel[i]].hide();
    			}
    		}
    	}
    
    }
    This function gets the info for the button just Moused Over... from the "this" passed into it. If there's a Menu involved... we get the name of that button. If not, we use a value of 'HomeLogout'.

    You named your Menus the same as your buttons... but with "MENU" appended. I'm going to take advantage of that. Whatever the incoming button name is... I'm going to uppercase it, and then append 'MENU'. Now we have the MenuName just Moused Over.

    Next, grab the {dialog.Object}._menus object and get its menu properties... these are any menus that have been opened... and add them to an array.

    Then loop through the array using .hide() on the MenuName... except for the current menu.

    The trick to figuring this out is to read the notes in the Menu Action for Show and Hide. This tells us jQuery is being used... and so that's what we need to use to close the Menus.

    Then, take one of your Menus... and turn it into code by selecting the Text Mode option in the Action. That gives us a wealth of code to work with.

    There is a bit that can be done to slim this down... but for the sake of explanation we're doing a bit more than needed. I don't think an array of MenuNames is really needed... and... this code will .hide() every menu except the current one... whether shown or not. We could test for an open menu.
    Last edited by Davidk; 03-18-2018 at 05:36 PM.

  5. #5
    Member
    Real Name
    Maroine A.
    Join Date
    Apr 2010
    Location
    Rabat, Morocco
    Posts
    122

    Default Re: getMenu method is not a function Error - Menus Action Js - Overlapping Menus on MouseOver - Browser Navigation Menu

    Thanks a lot David, your code solved the problem seamlessly.

    Much respect to you for your support and help in this forum. I certainly do appreciate it.

    Maroine

Similar Threads

  1. CSS lost when navigation menu opened in browser
    By bchankent in forum Mobile & Browser Applications
    Replies: 0
    Last Post: 07-08-2013, 05:28 PM
  2. Tabbed UI Hide Menu using Mouseover
    By chadbrown in forum Application Server Version 11 - Web/Browser Applications
    Replies: 29
    Last Post: 02-22-2012, 03:52 AM
  3. Customizable menus does not function
    By djm in forum Alpha Five Version 5
    Replies: 3
    Last Post: 01-16-2004, 08:36 AM
  4. No Menus
    By Charles Dingman in forum Alpha Five Version 5
    Replies: 4
    Last Post: 03-24-2003, 04:15 AM
  5. Sub menus in custom menu bars
    By Alejandro Marquez in forum Alpha Four Versions 7 and 8
    Replies: 0
    Last Post: 03-13-2003, 07:16 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •