ユーザーが注文を手配できる画像のリストがあります。
ユーザーが画像をアップロードしたときに、リストを引き続き並べ替え可能にしたい。
ここで説明されているのと同様のアップロードを使用しています:http://kpumuk.info/ruby-on-rails/in-place-file-upload-with-ruby-on-rails/
助けてください。
ビューファイルにアップロードするためのコードは次のとおりです。
<% form_for [:admin, @new_image], :html => { :target => 'upload_frame', :multipart => true } do |f| %>
<%= hidden_field_tag :update, 'product_images'%>
<%= f.hidden_field :image_owner_id %>
<%= f.hidden_field :image_owner_type %>
<%= f.file_field :image_file %><br />
or get image from this URL: <%= f.text_field :image_file_url %>
<%= f.hidden_field :image_file_temp %><br />
<%= f.submit "Upload Image" %>
<% end %>
そしてコントローラービューで:
def create
@image = Image.new(params[:image])
logger.debug "params are #{params.inspect}"
if @image.save
logger.debug "initiating javascript now"
responds_to_parent do
render :update do |page|
logger.debug "javascript test #{sortable_element("product_images", :url => sort_admin_images_path, :handle => "handle", :constraint => false)}"
page << "show_notification('Image Uploaded');"
page.replace_html params[:update], :partial => '/admin/shared/editor/images', :locals => {:object => @image.image_owner, :updated_image => @image}
page << sortable_element("product_images", :url => sort_admin_images_path, :handle => "handle", :constraint => false)
end
end
#render :partial => '/admin/shared/editor/images', :locals => {:object => @image.image_owner, :updated_image => @image}
else
responds_to_parent do
render :update do |page|
page << "show_notification('Image Upload Error');"
end
end
end
end
または、質問を言い換えると:
これを実行する:
page.replace_html params[:update], :partial => '/admin/shared/editor/images', :locals => {:object => @image.image_owner, :updated_image => @image}
page << sortable_element("product_images", :url => sort_admin_images_path, :handle => "handle", :constraint => false)
ソート可能なリスト機能は追加されません。
助けてください、
ありがとうございました