Reputation: 1700
I have a form that use selects and checkboxes.
For checkbox I use this method:
http://jsfiddle.net/nvanh/eomesgya/
The problem comes when I try to submit form on any change with:
$('#filter_form').on('change', function () {
console.log('submit');
});
If I change the select option the event fire but when I check a checkbox is not.
Here is the complete code:
http://jsfiddle.net/eomesgya/2/
Upvotes: 0
Views: 1483
Reputation: 320
You should bind Change Event to every input of your form, and this event should trigger the Submit event from your form.
$("#post-editor :input").each(function(){
// Every input of your form on $(this) scope
$(this).on('change', function () {
$("#post-editor").submit();
});
})
Upvotes: 0
Reputation: 3744
You should manually trigger change event if u manually change checked state:
$('.dropdown-menu a').on('click', function (event) {
....
setTimeout(function () {
$inp.prop('checked', true);
$inp.trigger('change'); // add this line
}, 0);
....
return false;
});
Upvotes: 1
Reputation: 937
You will need to bind it to each input element in the form, not just the form itself. Maybe try something like
$('#filter_form input').each(function() {
$(this).on('change', function () {
console.log('submit');
// Do submission stuff, submit form
});
});
https://api.jquery.com/submit/ As well if you need.
Upvotes: 1