Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,29 @@ $(document).on('pjax:timeout', function(event) {
})
```

### Options

The following options might be useful to customize behavior:

* `timeout` - A timeout on ajax requests
* `type` - The HTTP method to use (defaults to GET)
* `dataType` - Defaults to html
* `scrollTo` - A position to scroll the page to after pjax. Defaults to 0
* `maxCacheLength` - The number of history states to cache
* `fragment` - Set to load only a part of the target URL's content

By default, the `scrollTo` parameter causes each click to scroll to the top of the page. This simulates normal browsing behavior. To disable this behavior, set the `scrollTo` parameter to false.

``` javascript
$(document).pjax('a', '#pjax-container', {scrollTo: false});
```

or set a default for requests

``` javascript
$.pjax.defaults.scrollTo = false;
```

### Server side

Server configuration will vary between languages and frameworks. The following example shows how you might configure Rails.
Expand All @@ -244,6 +267,12 @@ An `X-PJAX` request header is set to differentiate a pjax request from normal XH

Check if your favorite server framework supports pjax here: https://gist.github.com/4283721

If you are not using a server framework that can detect the `X-PJAX` header (or if you are using static HTML files), use the `fragment` option to restrict what gets loaded.

``` javascript
$(document).pjax('a', '#pjax-container', {fragment: '#pjax-container'});
```

#### Layout Reloading

Layouts can be forced to do a hard reload assets or html changes.
Expand Down