How to have a checkbox fire an ajax call when checked or unchecked in Rails3? How to have a checkbox fire an ajax call when checked or unchecked in Rails3? ajax ajax

How to have a checkbox fire an ajax call when checked or unchecked in Rails3?


Add a class to your checkboxes, remove the obtrusive onclick and use jQuery to fire the form submit unobtrusively.

<%= t.check_box :provider_completed,   { :checked => task_assigned.provider_completed,   {:class => 'checkable'} } %>$('.checkable').live('change', function() {    $(this).parents('form:first').submit();});


I think that if you use the standard .submit() but add .submit();return false; to it you'll have it.