johncjensen / pjax_rails

PJAX integration for Rails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PJAX for Rails 3.2+

Build Status

Integrate Chris Wanstrath's PJAX into Rails 3.2+ via the asset pipeline.

To activate, add this to your app/assets/javascripts/application.js (or whatever bundle you use):

//=require jquery.pjax

Then choose all the types of links you want to exhibit PJAX:

// app/assets/javascripts/application.js
$(function() {
  $(document).pjax('a:not([data-remote]):not([data-behavior]):not([data-skip-pjax])', '[data-pjax-container]')
});

For this example, the PJAX container has to be marked with data-pjax-container attribute, so for example:

<body>
  <div>
    <!-- This will not be touched on PJAX updates -->
    <%= Time.now %>
  </div>

  <div data-pjax-container>
    <!-- PJAX updates will go here -->
    <%= content_tag :h3, 'My site' %>
    <%= link_to 'About me', about_me_path %>
    <!-- The following link will not be pjax'd -->
    <%= link_to 'Google', 'http://google.com', 'data-skip-pjax' => true %>
  </div>
</body>

About

PJAX integration for Rails


Languages

Language:Ruby 97.9%Language:JavaScript 2.1%