ページにJavaScriptを置く:レール2 replace_htmlは私が持っている私のコントローラで
私のRJSでrespond_to do |format|
format.js
end
:私の部分で
page.replace_html("source_credential_list", :partial => "source_credential_list", :object => @all_source_credentials)
または
page.replace("source_credential_list", :partial => "source_credential_list", :object => @all_source_credentials)
:(
<% fields_for(@brand_report_source_credential_key) do |ff| %>
<%= ff.select :source_credential_id , options_from_collection_for_select(@all_source_credentials,'id','credential_display_name')%>
<% end %>
私ORIGビューで
:
<span id="source_credential_list">
<%= render :partial => 'source_credential_list' %>
</span>
私はそれは素晴らしい作品置き換えるんが、スパンがなくなっているので、一度だけ、私がnullでアラートを取得する第二の時間が、私は疑います。私がreplace_htmlを行うと、それはちょっと動作します、それはスパンを更新しますが、実際のrjs/javascriptを新しいselect/dropを含むスパンに置きます。だからこのようなもの:
ソースの資格情報 try {Element.update( "source_credential_list"、 "\ n \ n \ n"); } catch(e){アラート( 'RJSエラー:\ n \ n' + e.toString());警告( 'Element.update(\ "source_credential_list \"、\ "\ n \ n \ n \");');スローe}
私はスパンを部分的に動かして両方のコンボを実行しようとしましたが、何も動作しませんでした。確かに何かが分かりました....
素晴らしいですが、それはonchange => remote_functionでしたが、それにも更新句がありました。 – Joelio