After reading the jquery-doc the answer is fairly easy:
Change:
$('#btnModelConfirmMessage').on('click',function () {
fun();
$('#msgModal').modal('hide');
});
Then add a new call on the hide.bs.modal event
$('#msgModal').on('hide.bs.modal',function () {
$('#btnModelConfirmMessage').off();
});
This removes the previously added handler, so we do not stack-up the events.
Hope someone will find this usefull :))
Cheers, Daniel
Answer from Daniel on Stack OverflowBootstrap
getbootstrap.com › docs › 4.6 › components › modal
Modal · Bootstrap v4.6
Bootstrap 4 has reached end of life. Upgrade to the latest or consider Never-Ending Support for your project. ... Use Bootstrap’s JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
Bootstrap 4 Modal as Confirm Revisited
I wanted to make a "flexible" confirm dialog with Bootstrap 4 as I do not want to hardcode each confirm modal / action on its own. So, with a standard Modal like More on stackoverflow.com
jquery - Open Bootstrap 4 Modal via JavaScript by clicking a link - Stack Overflow
I want to open a modal when I click on a link. Unfortunately I couldn't change the HTML of the link. I could only change the content of href. Like this: Open modal More on stackoverflow.com
bootstrap 4 modal
jose macedo is having issues with: when i click on my button for modal, my modal pops up but everything shifts to the left on my index.html please help More on teamtreehouse.com
Using Modal Dialog Boxes in Bootstrap 4
Not sure this article adds much more than the official documentation for the modal component...
https://getbootstrap.com/docs/4.1/components/modal/
More on reddit.comVideos
Modals In Bootstrap 4 || Learn Bootstrap
Bootstrap Modal - Complete Tutorial
Bootstrap 4 Modal popup Example | Create Popup using ...
11:11
Bootstrap 4 Tutorial: Modal Popups Made Easy - YouTube
How to open Bootstrap4 modal on page load / Show ...
Bootstrap 4 Tutorial: Modal Popups Made Easy
Wiley Online Library
ascpt.onlinelibrary.wiley.com › doi › epdf › 10.1002 › cpt.70201
American Society for Clinical Pharmacology and Therapeutics
3 weeks ago - Reader environment loaded · Loading publication (15.5 MB)
TutorialsPoint
tutorialspoint.com › bootstrap4 › bootstrap4_modal.htm
Bootstrap 4 - Modal
A static modal window example is shown in the following example − · <html lang = "en"> <head> <!-- Meta tags --> <meta charset = "utf-8"> <meta name = "viewport" content = "width = device-width, initial-scale = 1, shrink-to-fit = no"> <!-- Bootstrap CSS --> <link rel = "stylesheet" href = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin = "anonymous"> <title>Bootstrap 4 Example</title> </head> <body> <div class =" container"> <h2>Basic Modal</h2> <br> <!-- Button trigg
W3Schools
w3schools.com › bootstrap4 › bootstrap_modal.asp
Bootstrap 4 Modals
<!-- Button to Open the Modal --> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal"> Open modal </button> <!-- The Modal --> <div class="modal" id="myModal"> <div class="modal-dialog"> <div class="modal-content"> <!-- Modal Header --> <div class="modal-header"> <h4 class="modal-title">Modal Heading</h4> <button type="button" class="close" data-dismiss="modal">×</button> </div> <!-- Modal body --> <div class="modal-body"> Modal body..
W3Schools
w3schools.com › bootstrap4 › bootstrap_ref_js_modal.asp
Bootstrap JS Modal Reference
The following table lists all available modal events. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
Bootstrap
getbootstrap.com › docs › 4.0 › components › navbar
Navbar · Bootstrap
<div class="pos-f-t"> <div class="collapse" id="navbarToggleExternalContent"> <div class="bg-dark p-4"> <h4 class="text-white">Collapsed content</h4> <span class="text-muted">Toggleable via the navbar brand.</span> </div> </div> <nav class="navbar navbar-dark bg-dark"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> </nav> </div>
Top answer 1 of 3
28
Trigger click event on a[href$="#Modal"].
Copy$('a[href$="#Modal"]').on( "click", function() {
$('#Modal').modal('show');
});
Copy<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<!-- Trigger the modal with a button -->
<a href="#Modal" class="btn btn-info btn-lg">Open modal</a>
<!-- Modal -->
<div id="Modal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Run code snippetEdit code snippet Hide Results Copy to answer Expand
EIDT: changed myModal to Modal
2 of 3
3
need it to open after I click on the link.
So you'll need to check if the link is clicked.
jQuery provides many ways to select an element. http://api.jquery.com/category/selectors/
Copy$('a[href$="#Modal"]').on( "click", function() {
$('#Modal').modal();
});`
Bootstrap
getbootstrap.com › docs › 4.0 › utilities › borders
Borders · Bootstrap
Use border utilities to quickly style the border and border-radius of an element. Great for images, buttons, or any other element.
Drupal
drupal.org › project › bootstrap4_modal
Bootstrap 4 Modal | Drupal.org
February 13, 2024 - This module provides a bootstrap modal. Compatible with bootstrap 4 and bootstrap 5 themes.
Font Awesome
fontawesome.com
Font Awesome
The internet's icon library + toolkit. Used by millions of designers, devs, & content creators. Open-source. Always free. Always awesome.
UseBootstrap
usebootstrap.org › lang-en › components › modal
Modal
<template> <!-- Button trigger modal --> <b-button color="primary" toggle="modal" target="#exampleModal" > Launch demo modal </b-button> <!-- Modal --> <Modal id="exampleModal"> <ModalDialog> <ModalContent> <ModalHeader> <ModalTitle>Modal title</ModalTitle> <CloseButton dismiss="modal" /> </ModalHeader> <ModalBody>...</ModalBody> <ModalFooter> <b-button color="secondary" dismiss="modal" > Close </b-button> <b-button color="primary"> Save changes </b-button> </ModalFooter> </ModalContent> </ModalDialog> </Modal> </template>
Team Treehouse
teamtreehouse.com › community › bootstrap-4-modal
bootstrap 4 modal (Example) | Treehouse Community
October 4, 2016 - jose macedo is having issues with: when i click on my button for modal, my modal pops up but everything shifts to the left on my index.html please help