From 0212b4370b9e02b0cc234c28b300f0c5b12dff2d Mon Sep 17 00:00:00 2001 From: Oswaldo Acauan Date: Tue, 19 Nov 2013 20:16:11 -0200 Subject: [PATCH] fix(pjax): Fix back/foward #1 --- src/assets/js/scripts.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/assets/js/scripts.js b/src/assets/js/scripts.js index bf4abf59..f2c96480 100644 --- a/src/assets/js/scripts.js +++ b/src/assets/js/scripts.js @@ -45,6 +45,7 @@ if(Drawer.isOpen()) Drawer.close(); }); + $document.on('pjax:end', function() { if(ga !== undefined) { ga('set', 'location', window.location.href); @@ -55,16 +56,11 @@ NProgress.done(); }); - var pjaxHandler = function(e) { - $.pjax.click(e, { - container: '[data-pjax-container]', - fragment: '[data-pjax-container]', - replace: true - }); - }; + $document.pjax('a[data-pjax]', '[data-pjax-container]'); - $document.on('click', 'a[data-pjax]', pjaxHandler); - $document.on('submit', 'form[data-pjax]', pjaxHandler); + $document.on('submit', 'form[data-pjax]', function(e) { + $.pjax.submit(e, '[data-pjax-container]') + }) } // Data API bindings