Bootstrap 3/显示模式不适用于javascript方式 [英] Bootstrap 3 / showing modal doesn't work with the javascript way

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

问题描述

我使用 Bootstrap 3.0 中的 Modal 功能.

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方式启动时,即使链接只显示淡入淡出效果而没有模态.

可能是.. modal 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方法中没有提供url.

because there is no url provided in this js method.

这能解决你的问题吗?

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

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