Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rails/pjax_rails
PJAX integration for Rails
https://github.com/rails/pjax_rails
Last synced: about 7 hours ago
JSON representation
PJAX integration for Rails
- Host: GitHub
- URL: https://github.com/rails/pjax_rails
- Owner: rails
- License: mit
- Created: 2011-05-17T20:47:51.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2021-08-06T19:44:41.000Z (about 3 years ago)
- Last Synced: 2024-05-08T18:20:55.952Z (5 months ago)
- Language: Ruby
- Homepage:
- Size: 116 KB
- Stars: 668
- Watchers: 36
- Forks: 110
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
PJAX for Rails
===================
[![Build Status](https://travis-ci.org/rails/pjax_rails.png?branch=master)](https://travis-ci.org/rails/pjax_rails)Integrate Chris Wanstrath's [PJAX](https://github.com/defunkt/jquery-pjax) into
Rails via the asset pipeline.To activate, add this to your app/assets/javascripts/application.js (or whatever
bundle you use):```js
//=require jquery.pjax
```Then choose all the types of links you want to exhibit PJAX:
```js
// 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:```erb
<%= Time.now %>
<%= content_tag :h3, 'My site' %>
<%= link_to 'About me', about_me_path %>
<%= link_to 'Google', 'http://google.com', 'data-skip-pjax' => true %>
```
## Layouts
By default, the `pjax_rails` gem will not render your application layout file
and will instead only return the yielded view. But if you have additional
content you want to always be returned with your pjax requests, you can override
`pjax_layout` in your controller and specify a layout to render (by default,
it's `false`)```ruby
class ApplicationController < ActionController::Base
def pjax_layout
'pjax'
end
end
```