You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pjax fires a number of events regardless of how its invoked.
191
-
192
-
All events are fired from the container, not the link was clicked.
193
-
194
-
#### start and end
195
-
196
-
*`pjax:start` - Fired when pjaxing begins.
197
-
*`pjax:end` - Fired when pjaxing ends.
198
-
*`pjax:click` - Fired when pjaxified link is clicked.
199
-
200
-
This pair events fire anytime a pjax request starts and finishes. This includes pjaxing on `popstate` and when pages are loaded from cache instead of making a request.
201
-
202
-
#### ajax related
203
-
204
-
*`pjax:beforeSend` - Fired before the pjax request begins. Returning false will abort the request.
205
-
*`pjax:send` - Fired after the pjax request begins.
206
-
*`pjax:complete` - Fired after the pjax request finishes.
207
-
*`pjax:success` - Fired after the pjax request succeeds.
208
-
*`pjax:error` - Fired after the pjax request fails. Returning false will prevent the the fallback redirect.
209
-
*`pjax:timeout` - Fired if after timeout is reached. Returning false will disable the fallback and will wait indefinitely until the response returns.
210
-
211
-
`send` and `complete` are a good pair of events to use if you are implementing a loading indicator. They'll only be triggered if an actual request is made, not if it's loaded from cache.
190
+
All pjax events except `pjax:click` & `pjax:clicked` are fired from the pjax
191
+
container, not the link that was clicked.
192
+
193
+
<table>
194
+
<tr>
195
+
<th>event</th>
196
+
<th>cancel</th>
197
+
<th>arguments</th>
198
+
<th>notes</th>
199
+
</tr>
200
+
<tr>
201
+
<thcolspan=4>event lifecycle upon following a pjaxed link</th>
202
+
</tr>
203
+
<tr>
204
+
<td><code>pjax:click</code></td>
205
+
<td>✔︎</td>
206
+
<td><code>options</code></td>
207
+
<td>fires from a link that got activated; cancel to prevent pjax</td>
208
+
</tr>
209
+
<tr>
210
+
<td><code>pjax:beforeSend</code></td>
211
+
<td>✔︎</td>
212
+
<td><code>xhr, options</code></td>
213
+
<td>can set XHR headers</td>
214
+
</tr>
215
+
<tr>
216
+
<td><code>pjax:start</code></td>
217
+
<td></td>
218
+
<td><code>xhr, options</code></td>
219
+
<td></td>
220
+
</tr>
221
+
<tr>
222
+
<td><code>pjax:send</code></td>
223
+
<td></td>
224
+
<td><code>xhr, options</code></td>
225
+
<td></td>
226
+
</tr>
227
+
<tr>
228
+
<td><code>pjax:clicked</code></td>
229
+
<td></td>
230
+
<td><code>options</code></td>
231
+
<td>fires after pjax has started from a link that got clicked</td>
232
+
</tr>
233
+
<tr>
234
+
<td><code>pjax:success</code></td>
235
+
<td></td>
236
+
<td><code>data, status, xhr, options</code></td>
237
+
<td>after replacing HTML content loaded from the server</td>
238
+
</tr>
239
+
<tr>
240
+
<td><code>pjax:timeout</code></td>
241
+
<td>✔︎</td>
242
+
<td><code>xhr, options</code></td>
243
+
<td>fires after <code>options.timeout</code>; will hard refresh unless canceled</td>
0 commit comments