Invalid Syntax With JS Accordion Menu - SOLVED

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
kwag_myers
Propellus Maximus
Posts: 810
Joined: Wed Jul 25, 2012 11:36 am
Location: Ann Arbor, MI

Invalid Syntax With JS Accordion Menu - SOLVED

Post by kwag_myers »

I found this really simple accordion menu that was perfect for my project: w3schools.com. I added it to my MasterPage and all was well until I put the JavaScript in:

Code: Select all

			<script>
				var acc = document.getElementsByClassName("accordion");
				var i;

				for (i = 0; i < acc.length; i++) {
					acc[i].onclick = function(){
					this.classList.toggle("active");
					this.nextElementSibling.classList.toggle("show");
					}
					}
			</script>
Flare displays: "Warning: Invalid syntax on or inside " tag ..." I've tried systematically deleting the quotes. I also commented out the script and built the output, then removed the comment tags from the output and the menu works fine. But Flare won't build with the Script as is. Any ideas?
"I'm tryin' to think, but nothin' happens!" - Curly Joe Howard
kwag_myers
Propellus Maximus
Posts: 810
Joined: Wed Jul 25, 2012 11:36 am
Location: Ann Arbor, MI

Re: Invalid Syntax With JS Accordion Menu - SOLVED

Post by kwag_myers »

Solution: I needed to add CDATA tags.

Code: Select all

<script>/*<![CDATA[*/
var acc = document.getElementsByClassName("accordion");
var i;

for (i = 0; i < acc.length; i++) {
acc[i].onclick = function(){
this.classList.toggle("active");
this.nextElementSibling.classList.toggle("show");
}
}
/*]]>*/</script>
"I'm tryin' to think, but nothin' happens!" - Curly Joe Howard
Rona Kwestel
Sr. Propeller Head
Posts: 212
Joined: Wed Apr 04, 2007 11:50 am

Re: Invalid Syntax With JS Accordion Menu - SOLVED

Post by Rona Kwestel »

kwag_myers, did you use this for a single-level "menu" in your content, or did you get this to work for the TOC side menu proxy in the top nav output? I'm interested in doing the latter, but it seems like it involves a whole different level of complexity. Somehow, I'm guessing that this doesn't solve the problems discussed here: viewtopic.php?f=9&t=21607
Post Reply