Skip to content

Instantly share code, notes, and snippets.

@djforth
Forked from adrianstainforth/pjax_setup.js.coffee
Created November 7, 2012 12:50
Show Gist options
  • Save djforth/4031433 to your computer and use it in GitHub Desktop.
Save djforth/4031433 to your computer and use it in GitHub Desktop.
PJAX JavaScript
//= require jquery
//= require jquery_ujs
// Make sure you download latest PJAX code from https://github.com/defunkt/jquery-pjax
//= require jquery.pjax
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
#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