Exclude application layout in Rails 3 div

后端 未结 2 1951
逝去的感伤
逝去的感伤 2020-12-12 06:04

I\'m loading a template profile_messages as part of jQuery UI Tabs with Ajax. However when it loads, profile_messages inherits my site\'s applicati

相关标签:
2条回答
  • 2020-12-12 06:38

    In the controller, add at the end of the "show" action:

    render :layout => nil
    

    Or if you render from somewhere else just add the :layout => nil option to render.

    The better solution would be to make it a partial and call render :partial => "profile_messages/profile_message" (if you have the template in app/views/profile_messages/_profile_message.html.erb - note the _ in the filename!)

    Also instead of using escape_javascript it's actually simpler to ditch the " quotes and use (render ...).to_json.

    0 讨论(0)
  • 2020-12-12 06:57

    Do you have a response format of JS defined in your controller? It shouldn't render the layout if it renders a JS response properly. Do your logs show "responding with JS format"?

    respond_to do |format|
      format.js
    end
    

    As mrbrdo mentioned, you can also do render :layout => false but it shouldn't be necessary if the JS response is being run properly.

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