mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-10-03 07:45:21 +00:00
include request configuration in events
fixes https://github.com/bigskysoftware/htmx/issues/201
This commit is contained in:
parent
f984abb76d
commit
885596de09
@ -18,13 +18,13 @@
|
|||||||
htmx.defineExtension('path-deps', {
|
htmx.defineExtension('path-deps', {
|
||||||
onEvent: function (name, evt) {
|
onEvent: function (name, evt) {
|
||||||
if (name === "htmx:afterRequest") {
|
if (name === "htmx:afterRequest") {
|
||||||
var xhr = evt.detail.xhr;
|
var config = evt.detail.requestConfig;
|
||||||
// mutating call
|
// mutating call
|
||||||
if (xhr.method !== "GET") {
|
if (config.verb !== "get") {
|
||||||
var eltsWithDeps = htmx.findAll("[path-deps]");
|
var eltsWithDeps = htmx.findAll("[path-deps]");
|
||||||
for (var i = 0; i < eltsWithDeps.length; i++) {
|
for (var i = 0; i < eltsWithDeps.length; i++) {
|
||||||
var elt = eltsWithDeps[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");
|
htmx.trigger(elt, "path-deps");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1721,7 +1721,7 @@ return (function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var eventDetail = {xhr: xhr, target: target};
|
var eventDetail = {xhr: xhr, target: target, requestConfig:requestConfig};
|
||||||
xhr.onload = function () {
|
xhr.onload = function () {
|
||||||
try {
|
try {
|
||||||
if (!triggerEvent(elt, 'htmx:beforeOnLoad', eventDetail)) return;
|
if (!triggerEvent(elt, 'htmx:beforeOnLoad', eventDetail)) return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user