render a partial from jquery and haml

一曲冷凌霜 提交于 2019-12-03 15:50:23

To get the interpolation working you need to do something like

!= "$('.passenger-info ul').append('#{escape_javascript( render :partial => 'new_passenger', :locals => {:booking => @booking })}');

so simpler said: add the != to the start of the line, and include the string between double quotes.

Your question about the @booking: I suggest you investigate some nested forms examples to make it clearer for you (e.g. this and this railscast).

i actually managed to do this by adding:

respond_to do |format|
  format.js { render :partial => "new_passenger" }
end

so even if the request was in js, it will return an html partial. Nifty

Rails syntax changes all the time but shouldn't this

render :partial => "new_passenger", :locals {:booking => @booking })

be

render :partial => "new_passenger", :locals => {:booking => @booking })

You can escape javascript within the javascript block because you're evaluating ruby tags.

Which error messages are you receiving?

The latter part of your question isn't clear to me but is this what you're looking for:

- form_for @user do |f|
  # f.object is equal to @user
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!