Reputation: 207
I'm still fairly new to rails. I have a Product model, the product has about 20 attributes, such as size, cost, country, etc. Instead of showing all of the attributes I'd like to allow the user to select the attributes he/she is interested in and display only those.
What would be best practice for implementing this in rails 4?
Upvotes: 0
Views: 78
Reputation: 2255
I am assuming that you have a list of checkbox that user can click and see a specific set of values. This can be achieved using by simple jquery click() functionality. Ex- Lets say user only wants to 5 attributes, so he checks the 5 attributes of his choice by click the corresponding check boxes - shipping cost, amount, qty, discount and color. You can have jquery click event which will be invoked when customer selects the checkbox and display the values.
Ex -
$(document).ready(function(){
$(":checkbox").change(function(){
if($(this).attr("checked"))
{
//Display attribute
product.cost
}
});
});
Upvotes: 1