我有一個用戶可以安排他們的訂單的圖像列表。帶RJS的Sortable_element不起作用
當用戶上傳圖片時,我希望列表仍然可以排序。
我使用的是這裏所描述的相似上傳: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)
不會添加可排序列表功能。
請幫幫忙,
謝謝
所以...你有什麼建議? page <<「alert('damn rails bugs')」,但不知何故 page << sortable_element(「product_images」,:url => sort_admin_images_path,:handle =>「handle」,:constraint => false) 沒有得到任何調用。 你是如何解決這個問題的? – jaycode 2010-04-11 07:05:36