Issue
I'm building a Django project and trying to get and post data using htmx and everything works, which means I can get and post data there is no problem with that, but the problem is after data is swapped the bootstrap dropdown or tooltips or other elements that need some javascript to function including jQuery carousel is no longer working, I think the error is because after htmx swapped there is always new data added or replaced to the DOM, so the new data is no longer supported to any script.
so how can I handle this?
Update:
One solution that comes to my mind is to force the browser to re-load(re-download) scripts without a page refresh, but I have no idea how can I implement this, please help!
Solution
There is no need to reload your js source files.
What you need is htmx.onLoad
callback.
check here for more information.
htmx.onLoad(function(content) {
// reinitialize your bootstrap elements here
});
Answered By - fbzyx
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.