hx-post posting form inside a bootstrap modal
See original GitHub issueHi there, Thank you for providing such a great library.
I noticed when I try and use a form inside a bootstrap model, the hx-post doesn’t work?
<form hx-post="/hello">
<button class="btn btn-primary" type="submit">hello</button>
@Html.HtmxAntiforgeryScript()
</form>
It tries to post the original page rather than the modal dialog form. Is there some special scripting I need to do?
This is an example of something I’m trying to achieve https://blog.benoitblanchon.fr/django-htmx-modal-form/
Any exmaple or idea on how to fix this?
Issue Analytics
- State:
- Created 4 months ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
How to post data on submit in a Bootstrap modal?
1 Answer 1 ... Your Modal form is outside the form tag so, it is not part of the HTML form and hence...
Read more >Modal
Use Bootstrap's JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
Read more >Modal · Bootstrap v5.0
Use Bootstrap's JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
Read more >Modal forms with Django+HTMX - Good Code Smell
We set hx-target to this so that every HTMX request originating from the dialog (typically a form POST) remains in the dialog.
Read more >Server-powered modals with HTMX - .NET Tools Guide
Modals are a powerful way to get a user's attention when you're acknowledging their action. A modal typically contains the most important ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dotnetshadow 👋 Hi again. I updated the sample to use Bootstrap JavaScript to give you full access to all the Bootstrap intended behaviors.
The trick with HTMX is you can return
<script></script>
elements that will execute immediately. This allows you to pass the initialization script necessary for modals.Since the HTML and Script pass through HTMX’s request/response pipeline, you get a processed modal. Give it a try. It’s pretty sweet.
I’m writing a blog post about it 😃
No worries. Glad you’re trying out the library and enjoying it. Cheers.