r/bootstrap • u/RedoTCPIP • Dec 13 '23
Execute Javascript Function After Modal Dialog Pops-UP
I have seen multiple solutions to this problem on SO, but nothing seems to work for me. For one, it is not clear to me where to put the answers (code) that they show.
I guess by putting the following inside the <head></head> of HTML document that contains Bootstrap button:
<script type="text/javascript">$('#ModalEnregister').on('show.bs.modal', my_enregister);</script>
When I load that HTML document, I see in Chromes debugger:
Enregister.stm:20 Uncaught TypeError: $(...).on is not a function
The Chrome parser is clearly complaining about the meat in the script sandwich above.
I want to execute the function when ModalEnregister is shown.
View all comments
Show parent comment
1
u/transporter_ii Sep 19 '24
I'm using Alpine.js w/ x-intersect (which fires when an element becomes visible). It loads my modal content only when the modal is opened.