Created
July 6, 2009 21:04
-
-
Save cracell/141679 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<tr id='<%= item.html_id %>'> | |
<td><%= link_to_remote "X", :url => cart_line_item_path(item), :confirm => "Are you sure you want to remove the item?", :method => :delete, :class => "remove" -%></td> | |
<td> | |
<%= product_mini_image(item.product)%> | |
</td> | |
<td> | |
<%= link_to_product_name(item.product, true)%> | |
<% if item.size and item.product.valid_sizes %> | |
<p> | |
Size: <%= select_tag "size_select_#{item.id}", options_for_select(item.product.valid_sizes.collect{ |c| [c, c.to_s]}, item.size.to_s), {:onchange => remote_function(:url => { :controller => 'line_items', :action => 'size_select', :id => item.id }, :with => "'size=' + $('#size_select_#{item.id}').val()")} | |
%> | |
</p> | |
<% end %> | |
<% unless item.color.blank? %> | |
<p> | |
Color: <%= select_tag "color_select_#{item.id}", options_for_select(item.product.colors.collect{ |c| [c, c]}, item.color), {:onchange => remote_function(:url => { :controller => 'line_items', :action => 'color_select', :id => item.id }, :with => "'color=' + $('#color_select_#{item.id}').val()")} %> | |
</p> | |
<% end %> | |
</td> | |
<td class='price'> | |
<%=number_to_currency(item.price, :precision => 0)-%> | |
</td> | |
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def size_select | |
change_attribute(:size) | |
end | |
def color_select | |
change_attribute(:color) | |
end | |
def change_attribute(attribute) | |
line_item = LineItem.find(params[:id]) | |
line_item.update_attribute(attribute, params[attribute]) | |
respond_to do |format| | |
format.js { render :text => 'success'} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment