@@ -101,7 +101,7 @@ Or add `jquery-pjax` to your apps `bower.json`.
101
101
pjax can be downloaded directly into your app's public directory - just be sure you've loaded jQuery first.
102
102
103
103
```
104
- curl -O https://raw.github.com/defunkt/jquery-pjax/master/jquery.pjax.js
104
+ curl -LO https://raw.github.com/defunkt/jquery-pjax/master/jquery.pjax.js
105
105
```
106
106
107
107
** WARNING** Do not hotlink the raw script url. GitHub is not a CDN.
@@ -136,16 +136,40 @@ Or try this selector that matches any `<a data-pjax href=>` links inside a `<div
136
136
$ (document ).pjax (' [data-pjax] a, a[data-pjax]' , ' #pjax-container' )
137
137
```
138
138
139
- When invoking ` $.fn.pjax ` there are a few different argument styles you can use:
139
+ #### Arguments
140
140
141
- 1 . ` $(document).pjax(delegation selector, options object) `
142
- 2 . ` $(document).pjax(delegation selector, container selector, options object) `
141
+ The synopsis for the ` $.fn.pjax ` function is:
143
142
144
- In other words:
143
+ ``` javascript
144
+ $ (document ).pjax (selector, [container], options)
145
+ ```
146
+
147
+ 1 . ` selector ` is a string to be used for click [ event delegation] [ $.fn.on ] .
148
+ 2 . ` container ` is a string selector that uniquely identifies the pjax container.
149
+ 3 . ` options ` is an object with keys described below.
150
+
151
+ ##### pjax options
152
+
153
+ key | default | description
154
+ ----|---------|------------
155
+ ` timeout ` | 650 | ajax timeout in milliseconds after which a full refresh is forced
156
+ ` push ` | true | use [ pushState] [ ] to add a browser history entry upon navigation
157
+ ` replace ` | false | replace URL without adding browser history entry
158
+ ` maxCacheLength ` | 20 | maximum cache size for previous container contents
159
+ ` version ` | | a string or function returning the current pjax version
160
+ ` scrollTo ` | 0 | vertical position to scroll to after navigation
161
+ ` type ` | ` "GET" ` | see [ $.ajax] [ ]
162
+ ` dataType ` | ` "html" ` | see [ $.ajax] [ ]
163
+ ` container ` | | CSS selector for the element where content should be replaced
164
+ ` url ` | link.href | a string or function that returns the URL for the ajax request
165
+ ` target ` | link | eventually the ` relatedTarget ` value for [ pjax events] ( #events )
166
+ ` fragment ` | ` "body" ` | CSS selector for the fragment to extract from ajax response
167
+
168
+ You can change the defaults globally by writing to the ` $.pjax.defaults ` object:
145
169
146
- 1 . The first argument must always be a ` String ` selector used for delegation.
147
- 2 . The second argument can either be a ` String ` container selector or an options object.
148
- 3 . If there are three arguments the second must be the ` String ` container selector and the third must be the options object.
170
+ ``` javascript
171
+ $ . pjax . defaults . timeout = 1200
172
+ ```
149
173
150
174
### ` $.pjax.click `
151
175
@@ -406,3 +430,6 @@ $ open http://localhost:4567/
406
430
407
431
[ compat ] : http://caniuse.com/#search=pushstate
408
432
[ gist ] : https://gist.github.com/
433
+ [ $.fn.on ] : http://api.jquery.com/on/
434
+ [ $.ajax ] : http://api.jquery.com/jQuery.ajax/
435
+ [ pushState ] : https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history#Adding_and_modifying_history_entries
0 commit comments