Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72416

Listen to submit event with two form on same page

$
0
0

I'm creating a Javascript widget that generate a form, let's call it #widget-form created like this:

<form autocomplete="off" id="widget-form">
    <!-- Some inputs -->
</form>

I'm listening on submit event like this:

document.getElementById('widget-form').addEventListener('submit', function(event) {
    debugger;
}

And everything works fine.

BUT, when the widget is present on my Rails app webpage containing an another form (generated by simple_form), the Javascript is unable to catch my #widget-form submission event (my Chrome console don't breakpoint on debugger;)

PS: The page just reload when I submit my #widget-form form.

Is there a way to catch this event even if there is another form on the same webpage?


Viewing all articles
Browse latest Browse all 72416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>