I’m having trouble with the submit() function.
I need to submit a form after checking a checkbox, so I have a form in which I have a checkbox.
So when I do this, it’s working :
$(function() {
$("#myCheckbox").change(function() {
$(this).parentsUntil("#feuilles_form").parent().submit();
});
});
But it’s not working anymore when I’m trying something like this :
$(function() {
$("#myCheckbox").change(function() {
$(this).parentsUntil("#feuilles_form").parent().submit(function() {
.....
});
});
});
And I get no log from my console or firebug…
I need to do this cause I’ll have to use Ajax for the next step : refresh a div on my page.
Do you have any solution ?
Thx in advance !
Seb
By using
.submit(function(){})you are registering a function to call when the submit occurs.Try this:
Since you mention ajax, registering the anonymous function in the change event might cause multiple anonymous functions registered to the submit handler. example
It will most likely always be better to register the
.submit()once during dom ready.Example