From 37d2280a3d4441610ba1419111260d963ec905d1 Mon Sep 17 00:00:00 2001 From: Junle Date: Wed, 18 Jun 2014 16:16:01 +0800 Subject: [PATCH] Add definition and test for $.pjax.submit function. It is nearly same with $.pjax.click function. --- jquery.pjax/jquery.pjax-tests.ts | 7 +++++++ jquery.pjax/jquery.pjax.d.ts | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/jquery.pjax/jquery.pjax-tests.ts b/jquery.pjax/jquery.pjax-tests.ts index e5076a5a93b803..4d3c185919d39b 100644 --- a/jquery.pjax/jquery.pjax-tests.ts +++ b/jquery.pjax/jquery.pjax-tests.ts @@ -14,3 +14,10 @@ function test_click() { $.pjax.click(event, { container: "#pjax-container" }); $.pjax.click(event, "#pjax-container", { push: true }); } + +function test_submit() { + var event = $.Event("submit"); + $.pjax.submit(event, "#pjax-container"); + $.pjax.submit(event, { container: "#pjax-container" }); + $.pjax.submit(event, "#pjax-container", { push: true }); +} diff --git a/jquery.pjax/jquery.pjax.d.ts b/jquery.pjax/jquery.pjax.d.ts index aaeecf7d540ba1..b773dd461758c5 100644 --- a/jquery.pjax/jquery.pjax.d.ts +++ b/jquery.pjax/jquery.pjax.d.ts @@ -78,4 +78,25 @@ interface PjaxStatic { * - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false. */ click(event: JQueryEventObject, containerSelector?: string, options?: PjaxSettings): void; + + /** + * PJAX on form submit handler + * @param event A jQuery click event. + * @param options PJAX settings, which is a superset of jQuery AJAX settings. It includes the following specific options: + * - container: a jQuery selector indicates where to stick the response body. E.g., $(container).html(xhr.responseBody). + * - push: a boolean indicates whether to pushState the URL. Default is true. + * - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false. + */ + submit(event: JQueryEventObject, options?: PjaxSettings): void; + + /** + * PJAX on form submit handler + * @param event A jQuery click event. + * @param containerSelector A jQuery selector indicates where to stick the response body. E.g., $(containerSelector).html(xhr.responseBody). + * @param options PJAX settings, which is a superset of jQuery AJAX settings. It includes the following specific options: + * - container: a jQuery selector indicates where to stick the response body. The `containerSelector` parameter has priority. + * - push: a boolean indicates whether to pushState the URL. Default is true. + * - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false. + */ + submit(event: JQueryEventObject, containerSelector?: string, options?: PjaxSettings): void; }