Skip to content

Instantly share code, notes, and snippets.

@wombleton
Created May 30, 2011 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wombleton/999582 to your computer and use it in GitHub Desktop.
Save wombleton/999582 to your computer and use it in GitHub Desktop.
Prototype Pjax
/** Untested */
Ajax.Pjaxer = Class.create(Ajax.Updater, {
initialize: function($super, container, url, options) {
options = Object.clone(options);
options.headers = options.headers || {};
Object.extend(options.headers, {
'X-PJAX': 'true'
});
var onComplete = options.onComplete;
options.onComplete = (function(response, json) {
if(window.history && window.history.pushState) window.history.pushState({}, document.title, url);
if (Object.isFunction(onComplete)) onComplete(response, json);
}).bind(this);
$super(url, options);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment