<![CDATA[ add javascript to top level links in wayfinder - My Forums]]> https://forums.modx.com/thread/?thread=39752 <![CDATA[Re: add javascript to top level links in wayfinder]]> https://forums.modx.com/thread/39752/add-javascript-to-top-level-links-in-wayfinder#dis-post-230224 kjaebker Feb 21, 2007, 09:49 AM https://forums.modx.com/thread/39752/add-javascript-to-top-level-links-in-wayfinder#dis-post-230224 <![CDATA[Re: add javascript to top level links in wayfinder]]> https://forums.modx.com/thread/39752/add-javascript-to-top-level-links-in-wayfinder#dis-post-230223
I tried moving the <div id="expand"> outside of the <div id="expand15"> but it didn’t like that either. Any ideas? Thanks so much for your help!

<ul><li class="21">
<a href="javascript:toggleDisplayById(’expand15’)" title="Search Test">Search Test»</a>
<div id="expand15">
<div id="expand"><ul>
<li class="22"><a href="/site/mainlevel/2ndinner.html" title="Test -- 2nd inner level page" >Test -- 2nd inner level page</a></li>

</ul>
</div>
]]>
jam Feb 21, 2007, 09:31 AM https://forums.modx.com/thread/39752/add-javascript-to-top-level-links-in-wayfinder#dis-post-230223
<![CDATA[Re: add javascript to top level links in wayfinder]]> https://forums.modx.com/thread/39752/add-javascript-to-top-level-links-in-wayfinder#dis-post-230222 kjaebker Feb 20, 2007, 05:45 PM https://forums.modx.com/thread/39752/add-javascript-to-top-level-links-in-wayfinder#dis-post-230222 <![CDATA[Re: add javascript to top level links in wayfinder]]> https://forums.modx.com/thread/39752/add-javascript-to-top-level-links-in-wayfinder#dis-post-230221
Have the default innerTpl and for parentRowTpl use:

<li[+wf.classes+]>
	<a href="javascript:toggleDisplayById('expand[+wf.docid+]')" title="[+wf.title+]">[+wf.linktext+]»</a>
	<div id="expand[+wf.docid+]">[+wf.wrapper+]</div>
</li>

]]>
doze Feb 20, 2007, 05:14 PM https://forums.modx.com/thread/39752/add-javascript-to-top-level-links-in-wayfinder#dis-post-230221
<![CDATA[Re: add javascript to top level links in wayfinder]]> https://forums.modx.com/thread/39752/add-javascript-to-top-level-links-in-wayfinder#dis-post-230220 Any way to solve this? Should I use &rowIdPrefix? Instead of ’expand’ below, what code would I place to pull in the right unique id?

javascript:toggleDisplayById(’expand’)

]]>
jam Feb 20, 2007, 11:35 AM https://forums.modx.com/thread/39752/add-javascript-to-top-level-links-in-wayfinder#dis-post-230220
<![CDATA[Re: add javascript to top level links in wayfinder]]> https://forums.modx.com/thread/39752/add-javascript-to-top-level-links-in-wayfinder#dis-post-230219
<div id="expand">
	<ul[+wf.classes+]>
		[+wf.wrapper+]
	</ul>
</div>


for the javascript links you need to create a chunk for the template parentRowTpl like the following:

<li[+wf.classes+]>
	<a href="javascript:toggleDisplayById('expand')" title="[+wf.title+]">[+wf.linktext+]»</a>
	[+wf.wrapper+]
</li>


That should do it. Now the only problem you will have with this is if there is more than one submenu, it will have the same id as the first and cause problems. Also if a user has js disabled, the links will not function at all.]]>
kjaebker Feb 20, 2007, 10:01 AM https://forums.modx.com/thread/39752/add-javascript-to-top-level-links-in-wayfinder#dis-post-230219
<![CDATA[add javascript to top level links in wayfinder]]> https://forums.modx.com/thread/39752/add-javascript-to-top-level-links-in-wayfinder#dis-post-230218
I’m trying to figure out how to go about adding javascript to top level links with children in wayfinder. In other words, some of the top level links with no children will just be regular links, but the ones with children will toggle the children below when clicked. In addition, I need to add a div surrounding the second level links. (This will be a two-level menu). This is what I’d like the end output code to be:

<li><a href="javascript:toggleDisplayById(’expand’)">Top Level Link</a>
<div id="expand">
<ul>
<li><a href="tobeinserted">Second Level Link</a></li>
<li><a href="tobeinserted">Second Level Link</a></li>
</ul>
</div>
</li>

Can anyone point me in the right direction? I’m thinking I need to use the [+wf.link+] chunk? Any help is very much appreciated.

Thanks in advance!]]>
jam Feb 20, 2007, 09:51 AM https://forums.modx.com/thread/39752/add-javascript-to-top-level-links-in-wayfinder#dis-post-230218