hi there,
i copy a menu of javascript to an expression in a webblock:
https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_collapsible
where the javascript is like this:
<script>var coll = document.getElementsByClassName("collapsible");var i;for (i = 0; i < coll.length; i++) { coll[i].addEventListener("click", function() { this.classList.toggle("active"); var content = this.nextElementSibling; if (content.style.display === "block") { content.style.display = "none"; } else { content.style.display = "block"; } });}</script></body>
The trouble is that when i click the button menu, the collapsable works. Unfortunately, it submit to server. The question is How to make javascript not to submit to server?
thank you, best regards.
Hi Edu,
Thank you for quick reply.
We use our company's theme and wanna template like Dublin's. Then i copy that code, unfortunately when put in the Outsystems,it is submitted (different from the wwwschool). I guess this is the default of Outsystems's and then i put in the top of the javascript:
SyntaxEditor Code Snippet
event.preventDefault();
after changing the Javascript signature to:
coll[i].addEventListener("click", function(event) {
and fortunately, it works.. although i do not know the reason behind that.
regards,
Hello Pasar,
Not sure why you're using a JavaScript menu when OutSystems provides 2 level menu functionality out of the box (3 level is too much already).
In any case, your JavaScript does not submit to server (in a fast reading).
I would say the it is bound to an element that is inside a link.
Cheers