samedi 3 juin 2017

Rails get status from all checkboxes via jquery and send it to controller

So far I have the following setup:

My Checkboxes are declared like this:

<label id="cb2" class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-1">
     <input type="checkbox" id="checkbox-1" class="mdl-checkbox__input">
     <span class="mdl-checkbox__label">Meal</span>
</label>

And I have the following JQuery Code:

<script>
   $(document).ready(function() {
   $("input[type='checkbox']").change(function() {
       $("#change_me").html("<%= j render(partial: 'dynamic_test') %>");
     });
   });
</script>

So as soon as I check or uncheck a checkbox I want to get the check attribute of all checkboxes and send them to my controller(ajax?), where I then want to execute some select queries and render it in "dynamic_test". Could someone give me an idea on how to implement the data sending to my controller.




Aucun commentaire:

Enregistrer un commentaire