From b3c4df2576c7e2ff84cf71c6d645ad15538385a8 Mon Sep 17 00:00:00 2001 From: jspizziri Date: Mon, 25 Aug 2014 14:28:53 -0500 Subject: [PATCH 1/6] Cancel pjax on pjax:beforeReplace --- jquery.pjax.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jquery.pjax.js b/jquery.pjax.js index 5cec3f28..4746c8af 100644 --- a/jquery.pjax.js +++ b/jquery.pjax.js @@ -277,10 +277,13 @@ function pjax(options) { if (container.title) document.title = container.title - fire('pjax:beforeReplace', [container.contents, options], { + if(!fire('pjax:beforeReplace', [container.contents, options], { state: pjax.state, previousState: previousState - }) + })){ + return false; + } + context.html(container.contents) // FF bug: Won't autofocus fields that are inserted via JS. From 72114ec0d0cc267586b78bfc6c56a4f7f931d43b Mon Sep 17 00:00:00 2001 From: jspizziri Date: Mon, 25 Aug 2014 14:32:31 -0500 Subject: [PATCH 2/6] Update jquery.pjax.js --- jquery.pjax.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jquery.pjax.js b/jquery.pjax.js index 4746c8af..90c872b1 100644 --- a/jquery.pjax.js +++ b/jquery.pjax.js @@ -280,9 +280,8 @@ function pjax(options) { if(!fire('pjax:beforeReplace', [container.contents, options], { state: pjax.state, previousState: previousState - })){ - return false; - } + })) + return false context.html(container.contents) From bf5b3abf61b1b8c22ab257d10f27f53ff9a78417 Mon Sep 17 00:00:00 2001 From: Jacob Spizziri Date: Mon, 10 Nov 2014 16:20:15 -0600 Subject: [PATCH 3/6] pjax beforeReplace replacementHandler --- jquery.pjax.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/jquery.pjax.js b/jquery.pjax.js index 86075466..db2845c5 100644 --- a/jquery.pjax.js +++ b/jquery.pjax.js @@ -292,14 +292,16 @@ function pjax(options) { if (container.title) document.title = container.title - if(!fire('pjax:beforeReplace', [container.contents, options], { + var replacementHandler = fire('pjax:beforeReplace', [container.contents, options], { state: pjax.state, previousState: previousState - })) - return false - - context.html(container.contents) - + }) + + if(typeof replacementHandler === "function") + replacementHandler(container.contents, options) + else + context.html(container.contents) + // FF bug: Won't autofocus fields that are inserted via JS. // This behavior is incorrect. So if theres no current focus, autofocus // the last field. From c4bb63994b8057bdb097899b71d45db2dcda23f2 Mon Sep 17 00:00:00 2001 From: Jacob Spizziri Date: Tue, 11 Nov 2014 07:02:06 -0600 Subject: [PATCH 4/6] replacement handler in options --- jquery.pjax.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jquery.pjax.js b/jquery.pjax.js index db2845c5..8785471a 100644 --- a/jquery.pjax.js +++ b/jquery.pjax.js @@ -292,13 +292,13 @@ function pjax(options) { if (container.title) document.title = container.title - var replacementHandler = fire('pjax:beforeReplace', [container.contents, options], { + fire('pjax:beforeReplace', [container.contents, options], { state: pjax.state, previousState: previousState }) - if(typeof replacementHandler === "function") - replacementHandler(container.contents, options) + if(typeof options.replacementHandler === "function") + options.replacementHandler(container.contents, options) else context.html(container.contents) From 7297cc949890e0131111da67777b4a70ec1b475c Mon Sep 17 00:00:00 2001 From: Jacob Spizziri Date: Tue, 11 Nov 2014 10:12:30 -0600 Subject: [PATCH 5/6] add context as replacementHandler param --- .gitignore | 2 ++ jquery.pjax.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..8741cd7d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/nbproject/ +/nbproject/private/ diff --git a/jquery.pjax.js b/jquery.pjax.js index 8785471a..303c861f 100644 --- a/jquery.pjax.js +++ b/jquery.pjax.js @@ -298,7 +298,7 @@ function pjax(options) { }) if(typeof options.replacementHandler === "function") - options.replacementHandler(container.contents, options) + options.replacementHandler(context, container.contents, options) else context.html(container.contents) From 5254ebec84fcf94cf21a32066c7ef3bcb43e9af2 Mon Sep 17 00:00:00 2001 From: Jacob Spizziri Date: Mon, 24 Nov 2014 13:47:48 -0600 Subject: [PATCH 6/6] ignore bower components --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8741cd7d..3c53bb4f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +/bower_components/ /nbproject/ /nbproject/private/