이 문제를 검색했지만 해결책을 찾지 못했습니다.Rails/Facebox - 원격 기능으로 업데이트
양식의 이전 요소 선택에 따라 부분으로 대체되는 요소가있는 양식이 있습니다 (예 : 사용자가 "원본"을 선택하면 양식이 대상과 함께 대상을 업데이트합니다) collection_select 선택된 원점에서 사용 가능). 잘 작동합니다. Facebox 팝업에 모달로 표시 할 양식을 제외하고는 예외입니다.
현재 양식이 올바르게 그러나 폼 요소에는 onchange를 조치를 업데이트 할 것없는 facebox 팝업로드 ...보기에서
:
<%= link_to "New Delivery", new_delivery_requests_path, :remote => true %>
원격 호출 (보기/delivery_requests /new.js.erb) :
$.facebox('<%= escape_javascript(render 'new') %>')
새로운 레이아웃 (보기/delivery_requests/new.html.erb) :
<%= form_for @price_update do |f| %>
<% if @price_update.errors.any? %>
<h2>Errors:</h2>
<ul>
<% @price_update.errors.full_messages.each do |message|%>
<li><%= message %> </li>
<% end %>
</ul>
<% end %>
<br />
<table>
<tr>
<td><%= f.label "Select origin location: "%> </td>
<td><%= collection_select(:route, :origin_id, @origins, :id, :name,
{ :prompt => "Please select an origin" },
{ :onchange => "#{remote_function(
:url => { :action => "update_destinations"},
:with => "'origin_id='+value")}",
:id => "origin_select"})%>
</td>
</tr>
<tr>
<td><%= f.label "Select destination location: "%> </td>
<td><div id="destinations">
<%= collection_select(:route, :destination,
@available_routes, :id, :destination,
{ :prompt => "Please select an origin first" }, { :disabled => "disabled" })%></div></td>
</tr>
<tr>
<td><%= f.label "Current Prices: "%> </td>
<td>
<div id="current-prices-table"></div>
</td>
</tr>
<tr>
<td><%= f.label "Please select price option" %></td>
<td>
<div id = "price-selection"></div>
</td>
</tr>
<tr>
<td><%= f.label "Priority" %></td>
<td><%= f.label "Price Per Gram" %></td>
<td><%= f.label "Price per cm3" %></td>
</tr>
<tr>
<td><div id="priority-label"></div></td>
<td><%= f.text_field :new_price_per_gram, :id => "price_per_gram_textfield" %></td>
<td><%= f.text_field :new_price_per_vol, :id => "price_per_vol_textfield" %></td>
</tr>
</table>
<br />
<%= f.submit "Update Prices"%>
<% end %>
그리고 delivery_requests 컨트롤러의 업데이트 목적지 조치 :
def update_destinations
# updates the available list of destinations after an
# origin location has been chosen when making a new delivery request
sel_origin = Location.find(params[:origin_id])
@available_routes = Route.find_available_routes(sel_origin.name)
render :update do |page|
page.replace_html 'destinations', :partial => 'destinations_select', :object => @destinations
end
end
내가 레일 비교적 새로운 오전 - 어떤 충고가 이루어질 것입니다.
답변 해 주셔서 감사합니다. 나는 우리가 당시에 다른 접근법으로 갔다고 생각하지만 희망적으로 이것은 다른 사람들을 도울 수 있습니다. 건배. – jmc