From 4869631db5ef1f345d7b429be00bf6601841ee1e Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 21 Jan 2015 12:40:55 +0300 Subject: [PATCH] Added interface for pjax:popstate event --- jquery.pjax/jquery.pjax-tests.ts | 8 ++++++++ jquery.pjax/jquery.pjax.d.ts | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/jquery.pjax/jquery.pjax-tests.ts b/jquery.pjax/jquery.pjax-tests.ts index 7b08ca6c4..0df488130 100644 --- a/jquery.pjax/jquery.pjax-tests.ts +++ b/jquery.pjax/jquery.pjax-tests.ts @@ -58,3 +58,11 @@ function test_defauluts() { function test_support() { console.log($.support.pjax); } + +function test_events() { + $(document).on('pjax:popstate', function(e: PjaxPopStateEventObject) { + if (e.direction === 'back') { + console.log('pjax:popstate is OK'); + } + }); +} \ No newline at end of file diff --git a/jquery.pjax/jquery.pjax.d.ts b/jquery.pjax/jquery.pjax.d.ts index 48e48bcac..a3abee648 100644 --- a/jquery.pjax/jquery.pjax.d.ts +++ b/jquery.pjax/jquery.pjax.d.ts @@ -5,6 +5,16 @@ /// +/** + * Interface for pjax:popstate event. + */ +interface PjaxPopStateEventObject extends JQueryEventObject { + /** + * Navigation direction. Could be "back" or "forward". + */ + direction: string +} + interface PjaxSettings extends JQueryAjaxSettings { /** * A jQuery selector indicates where to stick the response body. E.g., $(container).html(xhr.responseBody).