Created
September 1, 2012 12:53
-
-
Save adamrobbie/3572520 to your computer and use it in GitHub Desktop.
Render view asynchronously.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
First put an empty, placeholder div in the main response | |
<div id="pink-dancing-elephants"></div> | |
and then add a little jQuery to the page | |
$.ajax({ | |
url: "/elephants/dancing", | |
cache: false, | |
success: function(html){ | |
$("#pink-dancing-elephants").append(html); | |
} | |
}); | |
and have the action that responses to /elephants/dancing/pink return the blob of HTML that you want to have fill up the div. In the action that is invoked by the AJAX request, you'll want to render with :layout => false to keep the returned blob of HTML from including the entire frame. E.g. | |
# elephants_controller.rb | |
def dancing | |
@elephants = #whatever | |
render :layout => false | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment