我使用 Modal来自 Bootstrap 3.0 的功能。
我有这个代码:
<a data-toggle="modal" href="/myNestedContent" data-target="#myModal">
Open the modal containing the content
</a>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
//nested content will be inserted here
</div>
当我点击 anchor (链接)时,整个工作 => 我看到了带有内容的模态。
但是,当我使用 Javascript 方式(而不是链接)来显示模态时:
$('#myModal').modal('show');
我只看到淡入淡出效果而没有显示模态...
当我开始点击链接,然后调用 javascript 时,它起作用了。 (副作用?)
当我通过 javascript 方式启动时,即使链接只显示淡入淡出效果,而没有模态。
可能是 .. modal
Javascript 方法的错误?
有关信息,我使用的脚本声明顺序正确:
<script src="//code.jquery.com/jquery.js"></script>
<script src="javascripts/jquery.form.min.js"></script>
<script src="javascripts/bootstrap.min.js"></script>
最佳答案
我不确定我是否误解了你的问题。
根据我对你问题的理解,你需要
$('#myModal').modal({
show: true,
remote: '/myNestedContent'
});
你不能只是
$('#myModal').modal('show');
因为这个js方法没有提供url
这是否解决了您的问题?
关于javascript - Bootstrap 3/显示模式不适用于 javascript 方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18423995/