Forums Archive Index > SmartMenus 5 > Idea regarding remote scripting
Date: 28 Apr 2005 10:04 am
Hi Vasil, just a brainstorm I had a few minutes ago.
If I have a menu with several submenus which contain dropdowns, they currently have to be preloaded.
However remote scripting (javascript based) can be used/triggered to populate a dropdown list.
We could set up SmartMenus to only trigger the database lookup to populate the dropdown for the lesser used menus when you actually mouse over them. So I guess... what I'm wondering was if there was a way to trigger javascript on Show. heh. If we could trigger another function (with a parameter) on show, then it'd be doable, I think. Any suggestions?
Date: 28 Apr 2005 11:16 am
And I'm also interested in working on this together, so if you want to send me an email, we can see if we can get this working..
Again, it shouldn't be that bad.
Date: 29 Apr 2005 3:09 am
Your idea is basically to pull the content from the database and create some of the menus at run-time right after (and only if) the user decides to display these menus, right?
I think this would result in very slow creation of the menus in question. On the other hand, it's won't be very simple to create a function that will be capable of building menus at run-time (it is even impossible in some old browsers). Because currently the script builds all menus before the page is loaded.
So I find your idea interesting but I don't think it is going to work well in practice. :?
Date: 29 Apr 2005 7:45 am
Sorry Vasil, I thought you might remember the site I am working on.
You can check it out at --> http://www.communityaccounts.ca.
Basically we're building level 2 and level 3 menus, which contain dropdowns (i.e. select lists).
One of the features of remote scripting, which you might not have used much at this point, is that it can use a javascript function to populate a select list on the fly from a database.
--> http://www.ashleyit.com/rs/jsrs/select/php/select.php
So yes, the menus are built "before" the page is. However, the dropdowns would not be filled until triggered by the function which runs on a Show submenu.
So I guess really, what I'm wondering, is could you help point out where in the script, if I wanted to add a function call within the function that runs when show runs, where should it go?
Date: 2 May 2005 5:39 pm
I now understand what you mean. Unfortunately, I am pretty busy these days and am not able to help you right now. :-( I will try to find some free time in the next couple of days and will see if I could do something about it.
I may contact you by email..
Date: 28 Jun 2005 1:27 pm
Any time nowadays? :wink:
Date: 30 Jun 2005 9:33 am
Actually.. no need now, I think. I've got it working on our development system. Pretty neat.
Date: 2 Sep 2005 12:39 pm
Sorry, turns out there is a question. I got it working using a function, called in s_script_dom near the DISABLED?"onmouseover=s_ov(this,"+a+ area...
It's just a function which passes a and i.
But a and i change a lot. Is there any token that I can pull in a similar way (title or something) on the mouseover? To pull what it is about to open?
Date: 3 Sep 2005 10:26 am
Well, you can use a and i like this:
s_[a][i].Show - this is the name of the sub menu the item shows (if there is any sub menu for this item).
So you can do something like this:
DISABLED?"onmouseover=s_ov(this,"+a+","+i+");if(s_["+a+"]["+i+"].Show)yourFunction(s_["+a+"]["+i+"].Show)
The code in green will act like this:
if(subMenuName)yourFunction(subMenuName)
e.g. the yourFunction(subMenuName) function will be called each time a sub menu is defined for the mouseovered menu item.
I hope this helps a bit!
Date: 7 Sep 2005 1:29 pm
FANTASTIC. I was using a and i, but hadn't figured Show out. I think that will be the missing link! I'll check it out.. If I can get it to production, I will definitely let you know!