Reputation: 8451
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) {
e.preventDefault();
debugger;
});
});
<%= form_for @changeset, upload_path(@conn, :create), [class: "upload-data-form", multipart: true], fn f -> %>
That ends up having this class .upload-data-form
When I submit the form the debugger in my Javascript is not working. What am I doing wrong?
Upvotes: 1
Views: 35
Reputation: 5473
$.noConflict();
jQuery( document ).ready(function( $ ) {
$("form.upload-data-form").submit(function(e) {
e.preventDefault();
debugger;
});
});
Upvotes: 1
Reputation: 9808
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) {
e.preventDefault();
debugger;
});
Upvotes: 1