File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -295,6 +295,24 @@ $(document).on('pjax:timeout', function(event) {
295
295
296
296
## Advanced configuration
297
297
298
+ ### Reinitializing plugins/widget on new page content
299
+
300
+ The whole point of pjax is that it fetches and inserts new content _ without_
301
+ refreshing the page. However, other jQuery plugins or libraries that are set to
302
+ react on page loaded event (such as ` DOMContentLoaded ` ) will not pick up on
303
+ these changes. Therefore, it's usually a good idea to configure these plugins to
304
+ reinitialize in the scope of the updated page content. This can be done like so:
305
+
306
+ ``` js
307
+ $ (document ).on (' ready pjax:end' , function (event ) {
308
+ $ (event .target ).initializeMyPlugin ()
309
+ })
310
+ ```
311
+
312
+ This will make ` $.fn.initializeMyPlugin() ` be called at the document level on
313
+ normal page load, and on the container level after any pjax navigation (either
314
+ after clicking on a link or going Back in the browser).
315
+
298
316
### Response types that force a reload
299
317
300
318
By default, pjax will force a full reload of the page if it receives one of the
You can’t perform that action at this time.
0 commit comments