mardi 25 avril 2017

how to use radio_button like check_box

hello everyone i have this code

 =form_tag products_path, method: :get, remote: true, id: "products_search" do
    =check_box_tag :search, "Bebes"

the above code is to search a product and works fine i get the event with JS to show the products with string "Bebes"

$('input[type=checkbox]').change () ->
  $.get $('#products_search').attr('action'), $('#products_search').serialize(), null, 'script'
  false

But i wanna use radio_button

i have this code:

=radio_button(:search, "search", "Bebes")

JS

$('input[type=radiobutton]').change () ->
  $.get $('#products_search').attr('action'), $('#products_search').serialize(), null, 'script'
  false

with the above code doesn't happen anything, someone can help me? i tried with this documentation http://ift.tt/2oul3jw but the param "search" is not a attribute of the Product model so i dont know how to do it :(

Aucun commentaire:

Enregistrer un commentaire