Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
663 views
in Technique[技术] by (71.8m points)

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...