Topic: Mdbootstrap - django - htmx

eirik_nordbo priority asked 4 months ago


Hi. I am building an app in Django and using mdbootstrap in the front. To make the app run smoothly i use htmx, but i am running into problems with the mdbootstrap elements because of the init. How can i solve this? Is it possible to use htmx and mdbootstrap alongside?

Expected behavior

Actual behavior

Resources (screenshots, code snippets etc.)


jaake free answered 2 months ago


Thanks, Kamila. I had much the same question.

Can you tell me how to initiate the elements with JS?

For comparison, I had a similar problem using moment and htmx. To fix that, I call "flask_moment_render_all" after the htmx swap. Can you tell me the corresponding JS function for mdb init?

... hx-on::after-swap="flask_moment_render_all()">


Kamila Pieńkowska staff commented 2 months ago

Every component have JS init example in Usage section of API Tab. Example for select: https://mdbootstrap.com/docs/standard/forms/select/#api-section-usage https://mdbootstrap.com/snippets/standard/kpienkowska/6052230

Alternatively you can use getOrCreateInstance method on every f.e. select on the page after you add content that way only select components that weren't initialized before.


Kamila Pieńkowska staff answered 4 months ago


Yes it is possible. But elements that are added after pageload need to be initiated with JS, since autoinit is performed on the pageload.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 7.2.0
  • Device: Pc
  • Browser: Edge
  • OS: Windows 11
  • Provided sample code: No
  • Provided link: No