Adding submenus on the fly when mouseover happens

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
tmakaro
Advanced
Advanced
Posts: 25
Joined: Thu Jan 26, 2006 10:43 pm

Adding submenus on the fly when mouseover happens

Post by tmakaro »

Hi, I have over 2000 menu items which is taking too long to load all at once. I have come up with a way of dynamically retrieving submenu data from the server using a hidden iframe.

I have also figured out (through the help of this forum) how to insert a submenu into the menu:

function test() {
with(milonic=new menuname("Samples")){
overflow="scroll";
style=menuStyle;
aI("text=World Map Sample;url=http://milonic.com/menusample92.php;")
aI("text=US Map Sample;url=http://milonic.com/menusample91.php;")
aI("text=Image Map Sample;url=http://milonic.com/menusample4.php;")
}
mm_createNewMenus();
}

My Question is how do I call my own function , such as the test() above, when I hover over a menu that should pop up a submenu? When the mouse pointer hovers over a menu, I need to call a function that checks to see if the submenu is loaded. If the submenu is not loaded, I need to retrieve it from the server, load it into the menu and then display it.

I am willing to share my retrieving js code to the community if anyone wants it. I just need a way of hooking it to the mouse over event.
Migru
Milonic Guru
Milonic Guru
Posts: 669
Joined: Tue Nov 01, 2005 8:22 pm
Location: Hamburg - Germany
Contact:

Post by Migru »

Hi

normally

onfunction=myfunction();

included in the aI string calls my own function. (mouse-on state) I´m using it. I´m not certain, if it works as expected in a string which pops up a submenu.

Michael
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Hi,

Onfunction and offfunction should work in strings which call a showmenu for a submenu.

Ruth
tmakaro
Advanced
Advanced
Posts: 25
Joined: Thu Jan 26, 2006 10:43 pm

Post by tmakaro »

i'm so close! The onfunction works great but i'm unable to display the menu.

Here is my example:
https://internal.tscsoftware.com/public ... /index.htm
and a snippet of the source:
for some reason 'itemOn' is failing.



<script type="text/javascript">
var got_it = false;

// onfunction defined in menu_data.js
function collectData() {
if (got_it == true) return;
// TODO go to server and get the submenu
setTimeout('myCallback()',1);
}

function myCallback() {
// this function will be called by the loaded document in the iframe

// TODO replace this code block with the one that gets the data from the iframe
with(milonic=new menuname("Samples")){
overflow="scroll";
style=menuStyle;
aI("text=Plain Text Horizontal Style DHTML Menu Bar;url=http://milonic.com/menusample1.php;")
aI("text=Vertical Plain Text Menu;url=http://milonic.com/menusample2.php;")
aI("text=Start Button Menu;url=http://milonic.com/menusample69.php;")
aI("text=Tramline;url=http://milonic.com/menusample54.php;")

}

mm_createNewMenus();
got_it = true;
menuNumber = getMenuByName("Samples");
alert("menuNumber = "+menuNumber);
itemOn(menuNumber); // this fails!
alert("here3");
}
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Hi,

I don't undertand what you mean. When I go to the page and mouseover menu samples I get an alert menuNumber = 6 Then when I click ok and mouseover the item again I get the submenu. So, what is supposed to happen?

Ruth
tmakaro
Advanced
Advanced
Posts: 25
Joined: Thu Jan 26, 2006 10:43 pm

Post by tmakaro »

I got it working. try this the following link. I can only have it here for a short time. Each sub-menu is loaded from the server. I will post my code later.

http://www.makaro.com:8080/nightly/milonic/index.htm
tmakaro
Advanced
Advanced
Posts: 25
Joined: Thu Jan 26, 2006 10:43 pm

Post by tmakaro »

oh, I forgot to mention, the submenus have only three options and are currently all the same. I have it hard coded on the server.

What the example shows is the web page retrieving the submenus from the server as required when the mouse is hovering over the parent.
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Hi,

That's terrific. The menu loaded really fast and the submenus open pretty quickly, also. If you can post how you did that so others might be able to use it in similar circumstances, it would be greatly appreciated.

Ruth
Post Reply