Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
812 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...