Ruby on Rails で、2 つのパーシャルを更新しようとしています。
show.html.erb:
<div id="filters"><%= render :partial => "pricelistfilters" %></div>
pricelistfilters.html.erb:
<% @properties.each do |prop| %>
#Render the page on properties (and the newproperties)
#<select ...><option>...</option><option>...</option>
#</select>
<% end %>
products.js --> レンダリングされたパーシャルのイベント
$(window).ready(function(){
selectionchanges();
});
function selectionchanges(){
$('#filters select').change(function(){
//Doing stuff to send with ajax
//Ajax:
$.ajax({
url: document.URL,
type: 'POST',
data: params
});
});
}
products_controller.rb --> 変更を処理するコード
def show
#Changing the properties (and the pricelist properties)
@properties #is filled
@newproperties #is filled
respond_to do |format|
format.html
format.js
end
end
show.js.erb
$('#filters').html('<%= escape_javascript(render :partial => "pricelistfilters") %>');
selectionChanges();
レンダリングされたアイテムは完全に良好です。ただし、レンダリングされたアイテムで適切な応答が得られると、もう ajax は送信されません。そのため、選択したアイテムのイベントはなくなりましたが、「selectionchanges();」でそれらをリセットしたことは確かです。show.js.erb ファイルの最後に?
誰でもこれに対する解決策を見ることができますか?
事前にご挨拶と感謝