How to set menu item 'selected' onClick using JavaScript.

Tigra Menu Gold is cross browser Javascript Menu navigation component for web sites offering most complete feature set

How to set menu item 'selected' onClick using JavaScript.

Postby nwbrd » Fri Sep 07, 2012 5:34 am

Hi All,

I am currently setting the menu item selected by wrapping the code inside [wrap_selected_child()], instead of [wrap_child()] on page refresh using PHP. Please refer below code snippet.
Code: Select all
<?php if ($currentPage == 'one'): ?>
   [wrap_selected_child
<?php else: ?>
   [wrap_child
<?php endif ?>
('One','one.gif'), "javascript:showScreen('one');", {'sb':'One'}],
<?php if ($currentPage == 'two'): ?>
   [wrap_selected_child
<?php else: ?>
   [wrap_child
<?php endif ?>
('Two','two.gif'), "javascript:showScreen('two');", {'sb':'Two'}],


We are now enhancing the code and now there is no page refresh. So the requirement is to set the menu item selected only onClick of it since there is no page refresh.

Can anyone help me achieving this ?

Regards.
nwbrd
 
Posts: 5
Joined: Fri Sep 07, 2012 5:07 am

Re: How to set menu item 'selected' onClick using JavaScript

Postby tigra » Sun Sep 09, 2012 9:48 pm

You can use the document inspector (Chrome has one built in, Firefox has it as add-on) to see the elements of the menu.

inspector-sshot.gif
Chrome's Document Inspector
inspector-sshot.gif (50.93 KiB) Viewed 1016 times


Then knowing the IDs/Classess of the elements you can use JavaScript to change the properties or content of individual menu elements via Document Object Model.
If this sounds too advanced then you can get a quote for a customized menu.
tigra
Site Admin
 
Posts: 30
Joined: Fri Jun 29, 2012 12:06 pm

Re: How to set menu item 'selected' onClick using JavaScript

Postby nwbrd » Tue Sep 11, 2012 10:53 pm

Thanks for your reply. I was also thinking like you suggested before posting.

On click of a menu, I's returning 'this' object in the java Script function e.g showScreen('one', this) . Though the object returned was a valid object but I can not access any of its property viz. name, id, class, parent, etc...

Regards.
nwbrd
 
Posts: 5
Joined: Fri Sep 07, 2012 5:07 am

Re: How to set menu item 'selected' onClick using JavaScript

Postby tigra » Thu Sep 13, 2012 8:01 pm

There are references from menu items to HTML elements representing them. You can contact softcomplex directly and request the formatted source so you can poke around/customize it.
You'll have to provide your invoice ID in your request.
tigra
Site Admin
 
Posts: 30
Joined: Fri Jun 29, 2012 12:06 pm


Return to Tigra Menu Gold

cron