include request configuration in events

fixes https://github.com/bigskysoftware/htmx/issues/201
This commit is contained in:
carson 2020-10-01 09:29:48 -06:00
parent f984abb76d
commit 885596de09
2 changed files with 4 additions and 4 deletions

View File

@ -18,13 +18,13 @@
htmx.defineExtension('path-deps', {
onEvent: function (name, evt) {
if (name === "htmx:afterRequest") {
var xhr = evt.detail.xhr;
var config = evt.detail.requestConfig;
// mutating call
if (xhr.method !== "GET") {
if (config.verb !== "get") {
var eltsWithDeps = htmx.findAll("[path-deps]");
for (var i = 0; i < eltsWithDeps.length; i++) {
var elt = eltsWithDeps[i];
if (dependsOn(elt.getAttribute('path-deps'), xhr.url)) {
if (dependsOn(elt.getAttribute('path-deps'), config.path)) {
htmx.trigger(elt, "path-deps");
}
}

View File

@ -1721,7 +1721,7 @@ return (function () {
}
}
var eventDetail = {xhr: xhr, target: target};
var eventDetail = {xhr: xhr, target: target, requestConfig:requestConfig};
xhr.onload = function () {
try {
if (!triggerEvent(elt, 'htmx:beforeOnLoad', eventDetail)) return;