AJAX in menu

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
WLQ's
Beginner
Beginner
Posts: 4
Joined: Thu Oct 11, 2007 3:06 pm

AJAX in menu

Post by WLQ's »

How can I change the normal url= in the menu into this so the menu will work?

<a onclick="DlePage('do=cat&category=main'); return false;" href="http://something.com/category/main/">Main page</a>
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Re: AJAX in menu

Post by Ruth »

Hi,

There is actually an ajax menu available I believe

http://milonic.com/ajaxmenus/

I will post to Milonic and ask about how to do what you want, but I kind of need to know what it is you're doing. I can many times figure out the solution, but I need an actual working page with the link in it to see what's going on and then I can test different things in a menu data file. I'm assuming that the part after the onclick is some kind of function. You can call functions in the url= ; for example:

at the top of the menu_data file before the first style you'd put the function

Code: Select all

var newwindow;
function mywindow(url)
{
   newwindow=window.open(url,'name','height=500,width=400,left=100,
  top=100,resizable=yes,scrollbars=yes,toolbar=yes,status=yes');

}
Then the aI would have

Code: Select all

I("text=item;url=javascript:mywindow('http://whatever/');");
Don't know if this is helpful or not, I'm out of my knowledge area :)

Ruth
WLQ's
Beginner
Beginner
Posts: 4
Joined: Thu Oct 11, 2007 3:06 pm

Re: AJAX in menu

Post by WLQ's »

I just need to put this function

<a onclick="DlePage('do=cat&category=main'); return false;" href="http://something.com/category/main/">Main page</a>

inside the url tag. But the problem is that menu doesn't understand ():, any of this inside the tag.
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Re: AJAX in menu

Post by Ruth »

Hi,

Well, it does understand it as far as I know, but I can't test yours because I don't know what the actual function is.

Take a look at this demos page which has a function called in the url parameter using url=javascript: then the function named followed by the (parameters) and it works fine.

http://support.milonic.com/demos/load_m ... /index.htm

This function is called in the aI string, in the url= parameter and it loads two pages at one time in two different iframes on a page. There is a full explanation on that page.
WLQ's
Beginner
Beginner
Posts: 4
Joined: Thu Oct 11, 2007 3:06 pm

Re: AJAX in menu

Post by WLQ's »

well the tutorial example did work but yours not, the function I gave you is the whole function, the actial ajax properties... is on my engine files, all I need is just to put the line which I gave you, if I put it instead of normal link the ajax function will work, so all i need is to put this line I gave you, i don't know well milonic maybe you can do as a function url=javascript and something like ajax function... or maake a fuction at the top of the page and recall it by url=javascript:2 or something, if you realy cannot find out how I will give you admin to my site to check how it will work
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Re: AJAX in menu

Post by Ruth »

Hi,

I'm sorry, I think I totally misunderstood you as you can see by my responses. I have posted to Milonic, but you might contact them directly.

I did actually get a link to work, but since I had to just put in a url that I could get to I have no idea if what you want would work. I mean I don't have any kind of site with a /category/main folders on it. And, I don't know if what I set up would work or not for you but try this, it should be all one line no wrapping. Of course you'll need to put in the correct http link unless your site is something dot com :) As I said, when I put my site in http://www.poems2u.com/writings/cyberpunk.html it worked fine, but that is a full url...

Code: Select all

aI("text=<a onclick=\"DlePage('do=cat&category=main')&#59 return false&#59\" href="http://websites.milonic.com/something.com/category/main/'>Main page</a>;type=html;");
Ruth
WLQ's
Beginner
Beginner
Posts: 4
Joined: Thu Oct 11, 2007 3:06 pm

Re: AJAX in menu

Post by WLQ's »

Oh it did work!!! Thank you very much you really are the PRO.

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

Re: AJAX in menu

Post by Ruth »

Hi,

I'm glad it works. Hopefully, I will get a response from Milonic on how to do this, because that is a difficult way, I think. I'll post back to here if they respond with an easier way.

I believe that if you actually use the ajax menu you would just put it in as you had it and it would then run through the ajax processor. I know that if someone is doing cold fusion or php and has those functions or commands in the items, they change the extension of the menu_data.js to .cfm or .php, this makes the data file go through those processors. [I think :? ]

Ruth
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Re: AJAX in menu

Post by Andy »

Hi,

There are several ways you can execute a Javascript function from within the menu.

Here's the easiest way:

Code: Select all

aI("text=Main Page;url=http://something.com/category/main/;clickfunction=DlePage('do=cat&category=main');custom=retFalse");
Note that there is a property called custom, this is used for returning either true or false so that the url is either executed or ignored.

If you want the menu item to execute the JavaScript function and follow the link to http://something.com/category/main/ you'll need to remove the custom property so that it looks like this:

Code: Select all

aI("text=Main Page;url=http://something.com/category/main/;clickfunction=DlePage('do=cat&category=main');");
If you want to execute the function but not follow the link to http://something.com/category/main/ put custom=retFalse"; into the aI string.

HTH,
Andy
Post Reply