diff --git a/jquery.pjax/jquery.pjax-tests.ts b/jquery.pjax/jquery.pjax-tests.ts index 4d3c18591..f394e7030 100644 --- a/jquery.pjax/jquery.pjax-tests.ts +++ b/jquery.pjax/jquery.pjax-tests.ts @@ -8,6 +8,14 @@ function test_fn_pjax() { $(document).pjax("a", "#pjax-container", { push: true }); } +function test_pjax() { + $.pjax(); + $.pjax({ + url: "hello.html", + container: "#main" + }); +} + function test_click() { var event = $.Event("click"); $.pjax.click(event, "#pjax-container"); diff --git a/jquery.pjax/jquery.pjax.d.ts b/jquery.pjax/jquery.pjax.d.ts index b773dd461..88118224d 100644 --- a/jquery.pjax/jquery.pjax.d.ts +++ b/jquery.pjax/jquery.pjax.d.ts @@ -58,6 +58,16 @@ interface JQueryStatic { } interface PjaxStatic { + /** + * Loads a URL with ajax, puts the response body inside a container, then pushState()'s the loaded URL. + * Works just like $.ajax in that it accepts a jQuery ajax settings object (with keys like url, type, data, etc). + * @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. + */ + (options?: PjaxSettings): JQueryXHR; + /** * PJAX on click handler. * @param event A jQuery click event.