Bootstrap 3 /显示模式不能与javascript方式一起使用 [英] Bootstrap 3 / showing modal doesn't work with the javascript way

查看:66
本文介绍了Bootstrap 3 /显示模式不能与javascript方式一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Bootstrap 3.0中的模态功能。

I use the Modal feature from 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>

当我点击锚点(链接)时,整个工作=>我看到模态与内容。

When I click on the anchor (the link), the whole works => I see the modal with the content.

然而,当我使用Javascript方式(而不是链接)来显示这样的模态时:

However, when I use the Javascript way (instead of the link) to show the modal like this:

$('#myModal').modal('show'); 

我只看到淡化效果而没有显示模态......

I only see the fade effect without the modal being shown...

当我点击链接开始时,然后调用javascript,它可以工作。 (副作用?)

当我以javascript方式开始时,即使链接仅显示没有模态的淡入淡出效果。

可能是.. 模态 Javascript方法的错误?

Might it be .. a bug from the modal Javascript method?

有关信息,我使用的脚本声明顺序正确:

For information, the declarations of my scripts that I use are in the right order:

<script src="//code.jquery.com/jquery.js"></script>
<script src="javascripts/jquery.form.min.js"></script> 
<script src="javascripts/bootstrap.min.js"></script>


推荐答案

我不确定我是否误解了你的问题。

i am not sure if i have misunderstood your question.

根据我对你的问题的理解,你需要

According to my understanding of your question, you need

$('#myModal').modal({
    show: true,
    remote: '/myNestedContent'
});

你不能只是

$('#myModal').modal('show'); 

因为此js方法中没有提供网址。

because there is no url provided in this js method.

这可以解决你的问题吗?

does this solve your question?

这篇关于Bootstrap 3 /显示模式不能与javascript方式一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆