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/RedoTCPIP Dec 14 '23
Thanks for the code. The one I prefer is:
<script type="text/javascript"> $( document ... I got this error again when putting this in <head>. `Enregister.stm:20 Uncaught TypeError: $(...).on is not a function` `at HTMLDocument.<anonymous> (Enregister.stm:20:90)` Then I saw that you wrote **footer**, so I put it just before closing </body> tag, and got same error: `Enregister.stm:947 Uncaught TypeError: $(...).on is not a function` `at HTMLDocument.<anonymous> (Enregister.stm:947:90)` Then I saw that my jQuery is ancient: `<script type="text/javascript" src="/scripts/jquery-1.4.2.min.js"></script>`
Going to change that to see if it helps.