My search field
These are my radio buttons
<% [ 'categorie', 'strutture', 'attivita', 'servizi' ].each do |type| %>
<%= radio_button_tag 'search_type', type, params[:search_type] == type %>
<%= type.humanize %>
<% end %>
i would like to render a partial as soon as one of them is selected.
I think this should be very similar to the ajax call i'm using for the instant search, that is:
this code in application.js
$("#facilities_search input").keyup(function() {
$.get($("#facilities_search").attr("action"), $("#facilities_search").serial开发者_JAVA百科ize(), null, "script");
return false;
});
and this in index.js.erb
$("#facilities").html("<%= escape_javascript(render("facilities")) %>");
Please can you help me? Thanks!
Ok, it was quite easy!
The point was to add this to my application.js
$("#search_type_categorie, #search_type_attivita, #search_type_servizi, #search_type_strutture").live("change", function() {
$.get($("#global_search").attr("action"), $("#global_search").serialize(), null, "script");
return false;
});
精彩评论