You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and the menu would replace #page-content of #outer-content using innerHTML so that outer-content would always exist. I would appreciate if anyone has some better idea though.
The text was updated successfully, but these errors were encountered:
BoPeng
changed the title
parentElement not ready when htmx tries to swap it with another element
parentElement of div not ready when htmx tries to swap it with another element using outerHTML
Feb 2, 2022
Is the error occuring in case of very fast navigation? Like when a developer crazily clicks his application to stress-test it 😇 ? If so, my advice is to setup some production client-side error monitoring, to see how often it happens to your real users. If you're sure that real users are impacted, innerHTML seems the only way to go 😉
This happens a lot when I quickly browse around the site since each click will replace a large trunk of the page with a fairly complex one and all the loading and rendering takes time. I have fixed the problem by using innerHTML but thought that htmx could adjust the timing so that the new element will not be displayed before it is "hooked" to its parentElememt.
I have an application with
where the
page-content
is replaced with another page usinghx-get
when users navigate through pages through a menu.I get errors from time to time, saying
Tracing into the code I find that, from time to time,
htmx/dist/htmx.js
Line 620 in f1cef92
the
<div>
'sparentElement
, which is thebody
element, isNULL
, causing this error.What appears to happen is that
<div>
is replacing#page-content
usingouterHTML
method<div>
is rendered, and the user clicks a link, which tries to replace<div>
with another<div>
.<div>
is not yet "hooked" to<body>
, causing the error.One solution that I can think of is to do
and the menu would replace
#page-content
of#outer-content
usinginnerHTML
so thatouter-content
would always exist. I would appreciate if anyone has some better idea though.The text was updated successfully, but these errors were encountered: