사용자가 주문할 수있는 이미지 목록이 있습니다.Sortable_element with RJS가 작동하지 않습니다.
사용자가 이미지를 업로드 할 때 목록을 계속 정렬 가능하게하고 싶습니다. 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)
정렬 가능 목록 기능을 추가하지 않습니다.
도와주세요은
는
그래서 ... 당신은 무엇을 제안합니까? 페이지 << alert ('damn rails bugs') "는 경보를 호출했지만 어떻게 든 페이지 << sortable_element ("product_images ", : url => sort_admin_images_path, : handle =>"handle ", : constraint => false) 아무 것도 호출되지 않습니다. 어떻게 해결 했습니까? – jaycode