drhenner / ror_ecommerce

Ruby on Rails Ecommerce platform, perfect for your small business solution.
www.ror-e.com
MIT License
1.21k stars 409 forks source link

Products filter #157

Closed ghost closed 9 years ago

ghost commented 9 years ago

David, We are trying to filter products based on check boxes. A criteria may have multiple check boxes and when each one of them is clicked, the data should further filter. This is similar to how Amazon does it too. We are preferring not to use the Submit button, as that makes the search less cleaner.

When we submit the form_to by using submit button it works. It also works with the links. However when we use the jquery to submit the form, the response is coming as a HTML string and rails is unable to render it.

Please find the code we used below for the same. Any guidance to help this work will be well appreciated.

<%= form_tag('/fetch_products', format: "js", remote: true, id: "states") do |f|%>

Shop By Region

<% states.each do |state| %> <% end %>
```

shop by craft

<%= fields_for crafts do |cra| %> <% crafts.each do |craft| %> <% end %> <% end %>
<%= submit_tag("Search")%> <% end %> ``` 1. $("#productsDiv").replaceWith("<%= escape_javascript(render(:partial => "index"))%>"); Thanks
drhenner commented 9 years ago

I'd probably do this in a different way. I'd bind a jQuery ajax call to a button then submit with jQuery. I don't have time to make the code for you right now but it shouldn't be too difficult.