このヘルパー関数を Ajax で更新しようとしています。
def radio_buttons_collection(types, invoice_type)
types_html = types.map do |type|
content_tag :span, :class => "radio_option" do
radio_button_tag("project[invoice_type]", type, type == invoice_type) + type
end
end
safe_join(types_html)
end
ただし、そこに2つのパラメーターを取得するのに問題があります。
# get_invoice_types.js.erb:
$('#project_invoice_type').html("<%= escape_javascript(radio_buttons_collection(@types, @invoice_type)) %>");
# projects_controller.rb:
def get_invoice_types
person = Person.find(params[:person_id])
@types = person.address_types
project = Project.find(params[:id])
@invoice_type = project.invoice_type
end
# application.js:
$("#project_person_id").change(function() {
$.ajax({
url: '/projects/get_invoice_types',
data: 'person_id=' + this.value,
dataType: 'script'
})
});
誰でも助けることができますか?
現在、@types
パラメーターのみが適切に渡されます。
助けてくれてありがとう!