https://github.com/eval/rack-pjax
pjax for rails and rack applications
https://github.com/eval/rack-pjax
Last synced: 7 months ago
JSON representation
pjax for rails and rack applications
- Host: GitHub
- URL: https://github.com/eval/rack-pjax
- Owner: eval
- License: mit
- Created: 2011-06-02T19:28:12.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2019-03-24T13:33:43.000Z (almost 7 years ago)
- Last Synced: 2025-04-12T12:52:33.727Z (9 months ago)
- Language: Ruby
- Homepage: http://rack-pjax.herokuapp.com/
- Size: 231 KB
- Stars: 205
- Watchers: 10
- Forks: 65
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Rack-pjax [](https://secure.travis-ci.org/#!/eval/rack-pjax)
========
Rack-pjax is middleware that lets you serve 'chrome-less' pages in respond to [pjax-requests](https://github.com/defunkt/jquery-pjax).
It does this by stripping the generated body; only the title and inner-html of the pjax-container are sent to the client.
While this won't save you any time rendering the page, it gives you more flexibility where and how to define the pjax-container.
Ryan Bates featured [rack-pjax on Railscasts](http://railscasts.com/episodes/294-playing-with-pjax) and explains how this gem compares to [pjax_rails](https://github.com/rails/pjax_rails).
[](http://railscasts.com/)
Installation
------------
Check out the [Railscasts' notes](http://railscasts.com/episodes/294-playing-with-pjax) how to integrate rack-pjax in your Rails 3.1 application.
You can find the source from the screencast over [here](https://github.com/ryanb/railscasts-episodes/tree/master/episode-294).
Another sample-app: the original [pjax-demo](http://pjax.herokuapp.com/) but with rack-pjax onboard can be found in the [sample-app](https://github.com/eval/rack-pjax/tree/sample-app) branch.
The more generic installation comes down to:
I. Add the gem to your Gemfile
```ruby
# Gemfile
gem "rack-pjax"
```
II. Include **rack-pjax** as middleware to your application(-stack)
```ruby
# config.ru
require ::File.expand_path('../config/environment', __FILE__)
use Rack::Pjax
run RackApp::Application
```
III. Install [jquery-pjax](https://github.com/defunkt/jquery-pjax). Make sure to add the 'data-pjax-container'-attribute to the container.
```html
...
$(function(){
$(document).pjax('a', '[data-pjax-container]')
})
...
...
```
(For more see [the docs of jquery-pjax](https://github.com/defunkt/jquery-pjax#usage).)
IV. Fire up your [pushState-enabled browser](http://caniuse.com/#search=pushstate) and enjoy!
Requirements
------------
- Nokogiri
Contributors
------
[The contributors](https://github.com/eval/rack-pjax/graphs/contributors).