mirror of
https://github.com/bigskysoftware/htmx.git
synced 2026-05-02 22:55:01 +00:00
Include full path w/ variables when pushing a GET
Fixes https://github.com/bigskysoftware/htmx/issues/58
This commit is contained in:
@@ -1447,7 +1447,9 @@ return (function () {
|
|||||||
});
|
});
|
||||||
// push URL and save new page
|
// push URL and save new page
|
||||||
if (shouldSaveHistory) {
|
if (shouldSaveHistory) {
|
||||||
pushUrlIntoHistory(pushedUrl || path);
|
var pathToPush = pushedUrl || finalPathForGet || path;
|
||||||
|
pushUrlIntoHistory(pathToPush);
|
||||||
|
triggerEvent(getDocument().body, 'pushedIntoHistory.htmx', {path:pathToPush});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,4 +131,41 @@ describe("hx-push-url attribute", function() {
|
|||||||
cache.length.should.equal(1);
|
cache.length.should.equal(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("afterSettle.htmx is called when replacing outerHTML", function () {
|
||||||
|
var called = false;
|
||||||
|
var handler = htmx.on("afterSettle.htmx", function (evt) {
|
||||||
|
called = true;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
this.server.respondWith("POST", "/test", function (xhr) {
|
||||||
|
xhr.respond(200, {}, "<button>Bar</button>");
|
||||||
|
});
|
||||||
|
var div = make("<button hx-post='/test' hx-swap='outerHTML'>Foo</button>");
|
||||||
|
div.click();
|
||||||
|
this.server.respond();
|
||||||
|
should.equal(called, true);
|
||||||
|
} finally {
|
||||||
|
htmx.off("afterSettle.htmx", handler);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should include parameters on a get", function () {
|
||||||
|
var path = "";
|
||||||
|
var handler = htmx.on("pushedIntoHistory.htmx", function (evt) {
|
||||||
|
path = evt.detail.path;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
this.server.respondWith("GET", /test.*/, function (xhr) {
|
||||||
|
xhr.respond(200, {}, "second")
|
||||||
|
});
|
||||||
|
var form = make('<form hx-trigger="click" hx-push-url="true" hx-get="/test"><input type="hidden" name="foo" value="bar"/>first</form>');
|
||||||
|
form.click();
|
||||||
|
this.server.respond();
|
||||||
|
form.textContent.should.equal("second")
|
||||||
|
path.should.equal("/test?foo=bar")
|
||||||
|
} finally {
|
||||||
|
htmx.off("pushedIntoHistory.htmx", handler);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user