Bitwise Bitwise - 3 years ago 93
Javascript Question

Listening for submit of form NOT working

I'm trying to disable some buttons on submit of form but I can't seem to get the function to work with my setup. Here is my Javascript:


$(document).ready(function() {
$("form.upload-data-form").submit(function(e) {


<%= form_for @changeset, upload_path(@conn, :create), [class: "upload-data-form", multipart: true], fn f -> %>

That ends up having this class
When I submit the form the debugger in my Javascript is not working. What am I doing wrong?

Dij Dij
Answer Source

Event handlers are bound only to the currently selected elements; they must exist on the page at the time your code makes the call to event handlers. try delegating events on children of the document object

$(document).on("submit","form.upload-data-form", function(e) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download