twitter-bootstrap 引导模式。Catch Uncaught TypeError: Object [object Object] 没有方法“modalmanager”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16593930/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 17:08:39  来源:igfitidea点击:

Bootstrap modal. Catch Uncaught TypeError: Object [object Object] has no method 'modalmanager'

javascriptjquerytwitter-bootstrapbootstrap-modal

提问by O.Zaiats

I get a:

我得到一个:

Uncaught TypeError: Object [object Object] has no method 'modalmanager' 

In my script.js file I have:

在我的 script.js 文件中,我有:

$('#addShoplistModal').modal('toggle');

Code of my jsp page:

我的jsp页面的代码:

<div class="modal hide fade" id='addShoplistModal'>
<div class='modal-header'>
    <a class='close' data-dismiss='modal'>×</a>
    <h3>Add Shopitem</h3>
</div>

<div class='modal-body'>
    <form id="addShopitemForm">
        <div id="name-error"></div>
        <input type="text" id="name" placeholder="Name" />
        <div id="quantity-error"></div> 
        <input type="text" id="quantity" placeholder="Quantity" />
    </form>
</div>

<div class='modal-footer'>
    <a class="btn" data-dismiss="modal">Cancel</a> 

        <a shoplistId="" id="add-shoplist" class="btn btn-primary">Add</a>
    </div>
</div>
    <script src="<spring:url value="/web/js/jquery-2.0.0.js" />"></script>
    <script src="<spring:url value="/web/js/jquery.validate.js" />"></script>
    <script src="<spring:url value="/web/js/bootstrap.js" />"></script>
    <script src="<spring:url value="/web/js/bootstrap-modal.js" />"></script>
    <script src="<spring:url value="/web/js/script.js" />"></script>

The error is at bootstrap-modal.js at

错误在 bootstrap-modal.js 处

manager = manager.appendModal ?
            manager : $(manager).modalmanager().data('modalmanager');

Tell me, please, how to fix this problem. Thanks.

请告诉我如何解决这个问题。谢谢。

回答by Ian

The bootstrap.jsfile shouldcontain all Bootstrap JavaScript features, such as the modal. Therefore, it's not necessary, and obviously breaks things, when you try to include the modal feature library a second time. Just remove bootstrap-modal.js.

bootstrap.js文件包含所有 Bootstrap JavaScript 功能,例如模态。因此,当您第二次尝试包含模态特征库时,这没有必要,而且显然会破坏事情。只需删除bootstrap-modal.js.

回答by Niranjan Sonachalam

I faced the same issue once. Check if you have added jQuery twice. If yes, remove the second jquery. It should work fine.

我曾经遇到过同样的问题。检查您是否已添加 jQuery 两次。如果是,请删除第二个 jquery。它应该可以正常工作。