Hello,
This seems like a simple Javascript question, but it’s not, since it’s typical for MODX and TV’s
I want to pass a multiline TV (RichText) to a Javascript function.
It’s done in one of the Wayfinder Template Chunks. And the TV holds additional information on the menu item. Together with the Balloon Javascript (see
http://gmod.org/wiki/Popup_Balloons) I want to pass the TV to the balloon function which generates the popup when a visitor hovers over the menu item.
- My WayFinder innerRowTpl looks like this:
[tt]<div class="menu3">
<h3 id="menuid[+wf.docid+]" onmouseover="plainBox.showTooltip(event,’[+menuText+]’);" ><a href="[+wf.link+]">[+wf.linktext+] </a></h3>
</div>[/tt]
- The TV is called menuText and it holds a piece of HTML (including newlines)
The problem:
When I want to pass the TV to a Javascript function it gives me the error "unterminated string literal"
because the [+menuText+] is put between quotes and the closing quote is on another line.
Why put this in the MODX forums and not hassle some Javascript forum:
Because all Javascript forums tell you of the "\" line continuation option. But I cannot use that here
because I would need to preprocess the TV.
Is there a solution to PreProcess a TV? Either at the moment it is saved to the database, or at the moment
it is used in a chunk? Then I can remove all the newlines in PHP.
Thanks in advance for your help.
Bert Catsburg