Skip to content

Instantly share code, notes, and snippets.

@livando
Created September 2, 2012 17:40
Show Gist options
  • Save livando/3602092 to your computer and use it in GitHub Desktop.
Save livando/3602092 to your computer and use it in GitHub Desktop.
Pjax implementation in Rails
1) add gem
2) create vendor directory, and download script
3) configure application.rb
4) write js that points the trigger to the displayer
5) ensure the trigger has the correct jquery selector
6) ensure the displayer has the correct jquery selector
1) add gem
gem 'rack-pjax'
2) create vendor directory, and download script
$ mkdir -p vendor/assets/javascripts
$ curl https://raw.github.com/defunkt/jquery-pjax/master/jquery.pjax.js > vendor/assets/javascripts/jquery.pjax.js
3) configure application.rb
module Store
class Application < Rails::Application
config.middleware.use Rack::Pjax
end
end
4) write js that points the trigger to the displayer
//= require jquery.pjax
jQuery => |pplication.css.
$('.code a').pjax('[data-pjax-container]')
5) ensure the trigger has the correct jquery selector
<div class="code">
<%= link_to code_topic.name, :code_id => code_topic %>
6) ensure the displayer has the correct jquery selector
<div data-pjax-container>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment