Created
October 18, 2011 15:20
-
-
Save nickhoffman/1295692 to your computer and use it in GitHub Desktop.
pjax is awesome, but causes code within #content_for not to be rendered. Here's a solution.
This file contains 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
module ApplicationHelper | |
def content_for_or_pjax(name, &block) | |
request.headers['X-PJAX'] ? capture(&block) : content_for(name, &block) | |
end | |
end |
This file contains 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
<%= content_for_or_pjax :javascript do %> | |
<script type='text/javascript'> | |
alert('Executing JS!'); | |
</script> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@dasch Simple and great idea. Thanks for sharing that.