mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-28 21:41:40 +00:00
Include full path w/ variables when pushing a GET
Fixes https://github.com/bigskysoftware/htmx/issues/58
This commit is contained in:
parent
6f14cba2e6
commit
a65c37ec4f
@ -1447,7 +1447,9 @@ return (function () {
|
||||
});
|
||||
// push URL and save new page
|
||||
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);
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user