Skip to content

Instantly share code, notes, and snippets.

@Ravenna
Created March 18, 2012 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ravenna/2081340 to your computer and use it in GitHub Desktop.
Save Ravenna/2081340 to your computer and use it in GitHub Desktop.
Product#Edit
<% content_for :javascripts do %>
<script>
$(function() {
$( "#add_photo" ).sortable();
$( "#add_photo" ).disableSelection();
});
</script>
<% end %>
<% content_for :javascripts do %>
<%= javascript_tag do %>
// Sorting the list
$(document).ready(function(){
$('#add_photo').sortable({
axis: 'y',
dropOnEmpty: false,
cursor: 'crosshair',
items: 'div',
opacity: 0.4,
scroll: true,
update: function(){
$.ajax({
type: 'post',
data: $('#add_photo').sortable('serialize'),
dataType: 'script',
complete: function(request){
$('#add_photo').effect('highlight');
},
url: 'sort_photos'})
}
});
});
<% end %>
<% end %>
<%= render :partial => 'shared/interior_hero' %>
<div id="interior_wrapper">
<div id="interior_header_absolute">
<h6 id="int_header">Edit</h6>
</div>
<div id="interior_sub_head"><h5 id="sub_green_head"><%= @product.title %></h5></div>
<div id="interior_pad">
<%= nested_form_for @product, :html => { :multipart => true } do |f| %>
<%= f.error_messages %>
<fieldset>
<legend>Basics</legend>
<p>
<%= f.label :title %><br />
<%= f.text_field :title %>
</p>
<p>
<%= f.label :description %><br />
<%= f.text_area :description %>
</p>
<p>
<%= f.label :price %> $<%= f.text_field :price %>
</p>
</fieldset>
<fieldset>
<legend>Categories and Spotlights</legend>
<p>
<%= f.label "Spotlight" %>
<%= select_tag "spotlight", options_for_select([ "New", "Vintage", "None" ], "None")%>
</p>
<p>
<%= f.label :category, "Category" %>
<%= f.select :category_id, Category.find(:all, :order => 'name').collect { |c| [c.name, c.id] }, :include_blank => true %>
</p>
<p>
<%= f.label :brand %>
<%= f.select :brand_id, Brand.find(:all, :order => 'name').collect { |b| [b.name, b.id] }, :include_blank => true %>
</p>
</fieldset>
<fieldset>
<legend>Add Photos</legend>
<div id="add_photo">
<%= f.fields_for :photos do |f|%>
<%= render :partial => "photo_fields", :locals => {:f => f} %>
<% end %>
</div>
<p><%= f.link_to_add "Add a Photo", :photos %></p>
</fieldset>
<p><%= f.label :audioclip %><br>
<%= f.file_field :audioclip %></p>
<p><%#= f.label :video %><br />
<%#= f.text_area :video %></p>
<p><%= f.submit 'Update' %></p>
<% end %>
<%= link_to 'Show', @product %> |
<%= link_to 'Back', products_path %>
</div>
</div>
<%= render :partial => 'shared/interior_footer' %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment