I'm using twitter bootstrap modal dialog. And it works fine while only opening it with
<a class="btn" data-controls-modal="my-modal" >Launch Modal</a>
But when I try something like
$('#close_popup').click(function(){ $('#rules').modal('toggle'); });
I get a javascript error:
bootstrap modal is not a function
Moreover. As far a I understand link with .close
must close the window and it doesn't. What do I do wrong?
To trigger the modal window, you need to use a button or a link. Then include the two data-* attributes: data-toggle="modal" opens the modal window.
Modals are built with HTML, CSS, and JavaScript. They're positioned over everything else in the document and remove scroll from the <body> so that modal content scrolls instead. Clicking on the modal “backdrop” will automatically close the modal. Bootstrap only supports one modal window at a time.
There are few ways to close modal in Bootstrap: click on a backdrop, close icon, or close button. You can also use JavaScript hide method. Click the button to launch the modal. Then click on the backdrop, close icon or close button to close the modal.
I don't know if you have figured out this issue or not being it was a couple months ago when you asked the question, but I came across the same problem and it had to do with a conflict with another plugin, so I will post the solution for future inquiries.
Here is an example of what I did to get around this issue.
function ShowImageInModal(path) { jQuery.noConflict(); (function ($) { $('#modalImage').removeAttr("src").attr("src", path); $('#myModal').modal('show'); } )(jQuery); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With