-
-
Save djforth/4031433 to your computer and use it in GitHub Desktop.
PJAX JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //= require jquery | |
| //= require jquery_ujs | |
| // Make sure you download latest PJAX code from https://github.com/defunkt/jquery-pjax | |
| //= require jquery.pjax | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require File.expand_path('../boot', __FILE__) | |
| module Myapp | |
| class Application < Rails::Application | |
| # Add gem 'rack-pjax' to gem file - More info go here https://github.com/eval/rack-pjax | |
| config.middleware.use Rack::Pjax | |
| #rest of application code here | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Checks if push state is available | |
| if (history && history.pushState) | |
| #sets higher time out other wise pjax aborts a lot | |
| $.pjax.defaults.timeout = 10000 | |
| $(document).pjax("a.pjax", "[data-pjax-container]").on "pjax:end", -> | |
| #Trigger code that needs to happen on page load |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment