Worked! Thank you~!
On Thursday, May 9, 2013 3:38:41 AM UTC-5, Niphlod wrote:
>
> it's exactly working as expected with the latest snippet.
>
> Il giorno giovedì 9 maggio 2013 00:15:38 UTC+2, Omi Chiba ha scritto:
>>
>> Thank you for the additional explanation.
>>
>> I just want to highlight the home by defaut only first time user access
>> the page. It should be removed when user click menu1 or menu2. The home
>> will be highlighted again when user click home.
>>
>> By default.
>> --------------------------
>> Home highlihgted
>> Menu1
>> Menu2
>>
>> User click menu1...
>> ----------------------------
>> Home
>> Menu1 highlihgted
>> Menu2
>>
>> User click Home again...
>> ------------------------------------
>> Home highlihgted
>> Menu1
>> Menu2
>>
>>
>>
>>
>>
>> On Wednesday, May 8, 2013 4:34:07 PM UTC-5, Niphlod wrote:
>>>
>>> ps: if you are on the case where you need to have home highlighted by
>>> default no matter what, use this javascript snippet (pretty straightforward)
>>> Added also a filter() to exclude the registration/login/etc links from
>>> being highlighted
>>>
>>> jQuery(function() {
>>> var path = location.pathname.substring(1);
>>> if ( path ) {
>>> var els = jQuery('ul.nav a[href$="'+path+'"]').filter(
>>> "[rel!=nofollow]");
>>> if (els.length != 0) {
>>> els.closest('li').addClass('highlighted');
>>> } else {
>>> jQuery('ul.nav a[href$="/highlight/default/index"]').closest
>>> ('li').addClass('highlighted');
>>> }
>>> }
>>> })
>>>
>>> PS: maybe to make it more clearer, use a Home link with an id, such as
>>>
>>> (SPAN('Home', _id='default_highlighted'), False, URL('default',
>>> 'index'), []),
>>>
>>> so you can switch the last line from
>>>
>>> jQuery('ul.nav a[href$="/highlight/default/index"]').closest('li').
>>> addClass('highlighted');
>>>
>>>
>>> to
>>>
>>>
>>> jQuery('#default_highlighted').closest('li').addClass('highlighted');
>>>
>>>
>>>
>>>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.