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).