@@ -295,6 +295,24 @@ $(document).on('pjax:timeout', function(event) {
295295
296296## Advanced configuration
297297
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+ 298316### Response types that force a reload
299317
300318By default, pjax will force a full reload of the page if it receives one of the
0 commit comments