This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Maybe it's just late and I'm tired, but I'm having a hard time getting javascript to run with October. Normally, I just place the code within a section, and call it a day. With October, it either prints the code as text, or gives an error. It doesn't seem to matter what the JS code is, so I'm thinking it's just an issue with where or how I'm calling it, but the official documentation is maddeningly vague on how to do this (or makes assumptions about what I already know).
Basically, the JS just creates an expandable menu, but here's the code. I don't think there's an issue with it, and it works fine under the live site (using another framework), but I'm including it just in case.
$(".navchild").hide("slow");
$(".navparent").click(function() {
if($(this).next('.navchild').is(':hidden')) {
$(".navchild").hide("slow");
$(this).next('.navchild').slideToggle("slow");
} else {
$(".navchild").hide("slow");
}
});
The ways I've attempted to do this are as follows:
-
Simply insert the code within a block. This just prints the code as text within the html.
- Add the code to a file called "assets/js/menu_hide.js" and attempt to call it via Twig at the bottom of the