Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap modal is not a function

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?

like image 868
iururu Avatar asked Dec 21 '11 07:12

iururu


People also ask

How do I enable modal?

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.

Does Bootstrap have modal?

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.

How do I turn off modal?

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.


1 Answers

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); } 
like image 76
Etch Avatar answered Oct 14 '22 14:10

Etch