2016-07-21 89 views
0

我正在使用Bootstrap和jQuery,并且我已经获得了使用文本属性触发打开的模式内容工作正常。bootstrap和jquery模式失败

不过,我想从另一个脚本关闭打开的模式窗口,我得到的是modal is not defined错误:

modals.js:94 Uncaught TypeError: $(...).modal is not a function(anonymous function) @ modals.js:94dispatch @ jquery.min.js:3r.handle @ jquery.min.js:3 
modals.js:86 Object {__ob__: Observer, __v-for__1: Fragment} 

的代码看起来是这样的:

$('#mymodal').modal('hide'); 

的加载顺序js文件是:

<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script> 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.js"></script> 
<script src="/modals.js" type="text/javascript"></script> 

如果模态风未定义ow从data-toggle="modal"电话正常工作?

回答

0

很多敲我的头后,这是由于jQuery的另一个版本正在导入通过我不知道的凉亭装置。一旦我知道在哪里看,它是一个简单的修复,以删除这个重复的jQuery和该网站按预期工作。

1

可能还有其它剧本重写bootsrap态函数$.fn.modal

如果这是真的,你需要解决冲突:

var bootstrapModal = $.fn.modal.noConflict(); 
$.fn.bootstrapModal = bootstrapModal; 
$('#mymodal').bootstrapModal('hide');