how to load an html fragment in rails with jquery? -
i wondering how may jquery.load
html fragment returned model's show
action. example, $("#container").load("/posts/34")
. problem returns view want embedded in layout, if visit url in browser. only want post
's show
html fragment.
thanks!
clarification: want show
view continue render within application layout when going show
action in browser. i'm merely trying figure out how fetch only html of show
view when want load asynchronously jquery. have seen guides in create show.js.erb
, render html view there, seems pretty messy me, escaping of html javascript. if accepted , proper way of doing though guess i'll follow standard. wondering if possible fetch html of particular view.
you can use :layout => false in render statement return fragment without layout:
def show ... render(:layout => false) if request.xhr? end
Comments
Post a Comment