Rails - AJAX to for new/create action

前端 未结 1 1413
刺人心
刺人心 2021-01-28 15:03

I\'ve got a timeline with events partials on it so that you can CRUD events directly on the timeline page. I\'ve got it working so that you can delete an event, and the delete p

1条回答
  •  闹比i
    闹比i (楼主)
    2021-01-28 15:31

    The :remote => true option on render :partial in the timelines/show view is not required.

    Instead the form_for in _new_event.html.erb should have the options :remote (this makes the form submit via ajax) and :format (this requests the response be in JavaScript), e.g.:

    <%= form_for event, :remote => true, :format => :js do |f| %>
    

    0 讨论(0)
提交回复
热议问题