samedi 5 septembre 2015

JQuery click event not submitting checkbox selections to controller

The user should be able to select multiple checkboxes and have an array of id's sent to the push products path..

This is my Jquery

<script type="text/javascript">
 $(document).ready(function() { 
    $('#button_to_push').click(function() {
    $('#submit_products').submit();
    });
 });
</script>

This is my rails button which is outside of my do loop

<div class="row pad_bottom col-md-4 col-md-offset-1 text-center">
  <button id="button_to_push" class="btn btn-primary btn-lg btn-block">
    <span class="glyphicon glyphicon-upload" aria-hidden="true"></span> 
    Push Selected Products
  </button>
</div>

Then finally these are my checkboxes:

<%= form_tag push_products_path, :id => 'submit_products' do  %>
  <% @products.each do |product| %>
  <tr>
    <td><%= check_box_tag('send[]', product.sellersku) %></td>
    <td><%= product.title %></td>
    <td><%= product.asin %></td>
  <% end %>
<% end %>

Where did I go astray?




Aucun commentaire:

Enregistrer un commentaire