AJAX Filtrar Productos

<html> <!-- SHOW BRAND_SPECS --> <!-- RADIO SELECTIONS --> <input type="radio" class="checkbox-filter" id="checkbox-1" subsubcategory_id="1"/> <label for="checkbox-1">Bases</label> <input type="radio" class="checkbox-filter" id="checkbox-2" subsubcategory_id="2"/> <label for="checkbox-2">Polvos</label> <input type="radio" class="checkbox-filter" id="checkbox-3" subsubcategory_id="3"/> <label for="checkbox-3">Rubores</label> <!-- PRODUCTS --> <div class="products-box" id="product-box"> <%= render "brand_specs/filtered_products", object: @filtered_products %> </div> </html> <html> <!-- PARTIAL FILTERED_PRODUCTS --> <% @filtered_products.each do |p| %> <a href="<%= product_path(p.product) %>" class="link"> <span class="brand"><%= p.product.brand.name %></span> <span class="name"><%= p.product.name %></span> </a> <% end %> </html> <script> // FILTER PRODUCTS $('input').on('change', function() { $.ajax({ url: "/brand_specs/" + $("#brand_spec_id").html() + "/filter_products?subsubcategory_id=" + $('input[name=checkbox-filter]:checked').attr("subsubcategory_id"), method: "POST", dataType: "jsonp", success: showProducts }) function showProducts(data) { // HELP??? } }); </script> <ruby> # brand_specs_controller.rb def show @filtered_products = @brand_spec.spec_products.where(subsubcategory: 1) end def filter_products @brand_spec = BrandSpec.friendly.find(params[:id]) @filtered_products = @brand_spec.spec_products.where(subsubcategory_id: params[:subsubcategory_id]) render @filtered_products # HELP! end </ruby>
cuando alguien elige una categoría (bases, polvos, rubores) logro mandar los parametros al servidor, se procesan, pero no puedo regresarlos a la vista... estan los extractos de:
show de BrandSpec,
partial _filtered_products.html.erb,
JS
controlador de BrandSpec

Gracias!

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.