Skip to content

Instantly share code, notes, and snippets.

@nclark
Created May 5, 2012 05:47
Show Gist options
  • Save nclark/2600165 to your computer and use it in GitHub Desktop.
Save nclark/2600165 to your computer and use it in GitHub Desktop.
--- pjax.orig.rb 2012-05-04 22:46:22.000000000 -0700
+++ pjax.rb 2012-05-04 22:46:57.000000000 -0700
@@ -13,6 +13,10 @@
headers = HeaderHash.new(headers)
if pjax?(env)
+ request_parameters = env['action_dispatch.request.parameters']
+ controller_name = request_parameters[:controller]
+ action_name = request_parameters['action']
+
new_body = ""
body.each do |b|
parsed_body = Hpricot.XML(b)
@@ -22,6 +26,13 @@
new_body << title.to_s if title
new_body << container.inner_html
+ new_body << <<-EOS
+ <script type="text/javascript">
+ $('body').removeClass();
+ $('body').addClass('#{controller_name}');
+ $('body').attr('id', '#{action_name}');
+ </script>
+ EOS
else
new_body << b
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment