Giter Club home page Giter Club logo

rack-pjax's Introduction

Rack-pjax travis

Rack-pjax is middleware that lets you serve 'chrome-less' pages in respond to pjax-requests.

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 and explains how this gem compares to pjax_rails.

railscast

Installation

Check out the Railscasts' notes how to integrate rack-pjax in your Rails 3.1 application.

You can find the source from the screencast over here.

Another sample-app: the original pjax-demo but with rack-pjax onboard can be found in the sample-app branch.

The more generic installation comes down to:

I. Add the gem to your Gemfile

# Gemfile
gem "rack-pjax"

II. Include rack-pjax as middleware to your application(-stack)

# config.ru
require ::File.expand_path('../config/environment',  __FILE__)
use Rack::Pjax
run RackApp::Application

III. Install jquery-pjax. Make sure to add the 'data-pjax-container'-attribute to the container.

<head>
  ...
  <script src="/javascripts/jquery.js"></script>
  <script src="/javascripts/jquery.pjax.js"></script>
  <script type="text/javascript">
    $(function(){
      $(document).pjax('a', '[data-pjax-container]')
    })
  </script>
  ...
</head>
<body>
  <div data-pjax-container>
    ...
  </div>
</body>

(For more see the docs of jquery-pjax.)

IV. Fire up your pushState-enabled browser and enjoy!

Requirements

  • Nokogiri

Contributors

The contributors.

rack-pjax's People

Contributors

dejan avatar eval avatar jasnow avatar koic avatar luizcosta avatar mshibuya avatar woodhull avatar yuroyoro avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.