Skip to content

Commit a2ae3d3

Browse files
committed
Merge remote-tracking branch 'origin/master' into abort-xhr
Conflicts: jquery.pjax.js
2 parents 5631350 + d3e5570 commit a2ae3d3

23 files changed

+701
-198
lines changed

.travis.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1+
sudo: false
12
language: ruby
23
rvm:
34
- 1.9.3
45

5-
install: gem install sinatra
6-
7-
before_script:
8-
- "export DISPLAY=:99.0"
9-
- "sh -e /etc/init.d/xvfb start"
10-
- ruby ./test/app.rb 2>/dev/null &
11-
- sleep 2
12-
13-
script: phantomjs ./test/run-qunit.coffee "http://localhost:4567/"
6+
install: script/bootstrap
7+
script: script/test
148

159
notifications:
1610
email: false

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
source 'http://rubygems.org'
22

3+
ruby '1.9.3'
4+
35
gem 'sinatra'
4-
gem 'json'

Gemfile.lock

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
GEM
22
remote: http://rubygems.org/
33
specs:
4-
json (1.8.1)
54
rack (1.5.2)
65
rack-protection (1.5.3)
76
rack
@@ -15,5 +14,4 @@ PLATFORMS
1514
ruby
1615

1716
DEPENDENCIES
18-
json
1917
sinatra

README.md

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Or add `jquery-pjax` to your apps `bower.json`.
101101
pjax can be downloaded directly into your app's public directory - just be sure you've loaded jQuery first.
102102

103103
```
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
105105
```
106106

107107
**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
136136
$(document).pjax('[data-pjax] a, a[data-pjax]', '#pjax-container')
137137
```
138138

139-
When invoking `$.fn.pjax` there are a few different argument styles you can use:
139+
#### Arguments
140140

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:
143142

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` | | 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:
145169

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+
```
149173

150174
### `$.pjax.click`
151175

@@ -174,6 +198,14 @@ $(document).on('submit', 'form[data-pjax]', function(event) {
174198
})
175199
```
176200

201+
### `$.pjax.reload`
202+
203+
Initiates a request for the current URL to the server using pjax mechanism and replaces the container with the response. Does not add a browser history entry.
204+
205+
``` javascript
206+
$.pjax.reload('#pjax-container', options)
207+
```
208+
177209
### `$.pjax`
178210

179211
Manual pjax invocation. Used mainly when you want to start a pjax request in a handler that didn't originate from a click. If you can get access to a click `event`, consider `$.pjax.click(event)` instead.
@@ -336,7 +368,7 @@ Check if your favorite server framework supports pjax here: https://gist.github.
336368

337369
#### Layout Reloading
338370

339-
Layouts can be forced to do a hard reload assets or html changes.
371+
Layouts can be forced to do a hard reload when assets or html changes.
340372

341373
First set the initial layout version in your header with a custom meta tag.
342374

@@ -406,3 +438,6 @@ $ open http://localhost:4567/
406438

407439
[compat]: http://caniuse.com/#search=pushstate
408440
[gist]: https://gist.github.com/
441+
[$.fn.on]: http://api.jquery.com/on/
442+
[$.ajax]: http://api.jquery.com/jQuery.ajax/
443+
[pushState]: https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history#Adding_and_modifying_history_entries

bower.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{
22
"name": "jquery-pjax",
3-
"version": "1.8.2",
3+
"version": "1.9.4",
44
"main": "./jquery.pjax.js",
55
"dependencies": {
66
"jquery": ">=1.8"
77
},
88
"ignore": [
99
".travis.yml",
10+
"Gemfile",
11+
"Gemfile.lock",
12+
"vendor/",
13+
"script/",
1014
"test/"
1115
]
1216
}

0 commit comments

Comments
 (0)