GithubHelp home page GithubHelp logo

redross / rack-pjax Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kpfefferle/rack-pjax

1.0 2.0 0.0 213 KB

pjax for rails and rack applications

Home Page: http://rack-pjax.heroku.com/

License: MIT License

Ruby 100.00%

rack-pjax's Introduction

Rack-pjax stillmaintained travis

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

It does this by simply filtering the generated page; 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 or how to define the pjax-container. Ryan Bates featured rack-pjax on Railscasts and explains how this gem compares to pjax_rails.

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(){
          $('a:not([data-remote]):not([data-behavior]):not([data-skip-pjax])').pjax('[data-pjax-container]')
        })
      </script>
      ...
    </head>
    <body>
      <div data-pjax-container>
        ...
      </div>
    </body>

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

Requirements

  • Hpricot

Contributors

rack-pjax's People

Contributors

eval avatar kpfefferle avatar luizcosta avatar redross avatar

Stargazers

 avatar

Watchers

 avatar  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.