lively-waitress-29714
01/31/2023, 9:19 AM<div class="dc-content" hx-get="/endpoint" hx-trigger="every 1s" hx-swap="morphdom">
<div id="dc-session-details">test</div>
</div>
On each subsequent request /endpoint
will just return the inner div:
<div id="dc-session-details">test</div>
However, attempting to mark/highlight the text "test" with the mouse doesn't work, because it is replaced on every second. Looking at the DOM with the browser's webdev tools also looks like the inner div is replaced each time. Is that the intended behaviour? My expectation was that only content that differs is swapped/morphed, but maybe I just didn't get the idea behind morphing.rich-coat-84078
01/31/2023, 10:28 AM**htmx.onLoad(function() **
doubling on every load to dom. as you see on screenshot down bellow
I have a problem with the following code.
unSetClasses
> htmx.onLoad(function(elt))
with the form reload after the form is reloaded and the #product_update_close button works. otherwise the button works once and does not work when the form is reloaded ajax (when i clicked to update button).
However, every time I open and close the form, htmx.onLoad(function(elt)
increases by one, that is, it stays in the dom even though the form is closed. when I click again, it does the same thing twice, three times when I click again.
(function(){
function setClasses(evt) {
let active_row = evt.detail.elt.offsetParent
active_row.classList.add("active-row");
htmx.addClass(htmx.find('body'), 'update-On');
}
function setAfterSettle(evt) {
htmx.on("htmx:afterSettle", function (evt) {
setActiveRowIndex()
});
}
function unSetClasses(evt) {
htmx.onLoad(function() {
htmx.on("#product_update_close", "click", function() {
htmx.removeClass(htmx.find('body'), 'update-On');
htmx.removeClass(htmx.find('.active-row'), 'active-row');
htmx.remove(htmx.find("#product_form_container"), 600);
});
console.log('Log htmx.onLoad')
})
}
htmx.defineExtension('set-update', {
onEvent : function(name, evt) {
if (name === "htmx:afterRequest") {
setClasses(evt);
setAfterSettle(evt);
unSetClasses(evt);
}
}
});
})();
ripe-action-67367
01/31/2023, 11:05 AMripe-action-67367
01/31/2023, 11:11 AMrich-coat-84078
01/31/2023, 1:04 PMbumpy-kangaroo-60192
01/31/2023, 4:47 PMmysterious-toddler-20573
01/31/2023, 4:56 PMbumpy-kangaroo-60192
01/31/2023, 4:57 PMadventurous-ocean-93733
01/31/2023, 8:11 PMicy-motherboard-95213
01/31/2023, 8:31 PMadventurous-ocean-93733
01/31/2023, 8:34 PMhtmx.logAll();
?adventurous-ocean-93733
01/31/2023, 8:34 PMripe-action-67367
01/31/2023, 8:35 PMicy-motherboard-95213
01/31/2023, 8:36 PMicy-motherboard-95213
01/31/2023, 8:36 PMripe-action-67367
01/31/2023, 8:36 PMripe-action-67367
01/31/2023, 8:37 PMripe-action-67367
01/31/2023, 8:37 PMripe-action-67367
01/31/2023, 8:38 PMripe-action-67367
01/31/2023, 8:38 PMicy-motherboard-95213
01/31/2023, 8:38 PMicy-motherboard-95213
01/31/2023, 8:38 PMicy-motherboard-95213
01/31/2023, 8:39 PMripe-action-67367
01/31/2023, 8:40 PMripe-action-67367
01/31/2023, 8:42 PMicy-motherboard-95213
01/31/2023, 8:42 PMicy-motherboard-95213
01/31/2023, 8:43 PMicy-motherboard-95213
01/31/2023, 8:43 PMrefined-manchester-67193
01/31/2023, 10:53 PM