I'm trying out jQuery with Rails and I faced this problem. I want to have a jQuery submit handler for a button_to tag like this
<%= button_to "+", action: "execute", operation: "add", operand: "1" %>
which is actually converted to a form in the DOM like so
<form class="button_to" method="post" action="/execute?operand=1&operation=add">
<input type="submit" value="+">
<input type="hidden" name="authenticity_token" value="mre8xqU4RBk2u+vCLrMQHYUHTNWtk0Ebn45OnvlXxUZcofqxArt9ZXJN63QlNq8Kei08FFo6Y4+OQgwH+vsVNw==">
</form>
I added a submit handler for this form which looks like this
$(document).ready(function(){
("form").submit(function(){
alert("here");
});
});
The alert doesn't get displayed when I submit the form. I also tried the solution of this question but it didn't help.
My aim is to set the value of the value of the operand attribute in the button_to tag to $(".operand").text() inside the submit handler. Operand is another text field in which the user has entered a numeric value.