简体   繁体   English

Twitter Bootstrap 3模式对话框不显示

[英]Twitter Bootstrap 3 modal dialog not displaying

I have a twitter bootstrap modal that does not render the dialog box correctly and I'm not sure why. 我有一个twitter引导程序模式,该模式无法正确显示对话框,而且我不确定为什么。

HTML 的HTML

<p class="text-center btn-p"><button class="btn btn-warning" data-toggle="modal" data-target="#myModal2">Compare</button></p>

<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModal2Label" aria-hidden="true">
 <div class="modal-dialog modal-lg">
    <div class="modal-content">
     <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
         <h4 class="modal-title" id="myModal2Label">New Label</h4>
     </div>
    <div class="modal-body">
        <p>Something for now.</p>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    </div>
  </div>
 </div>
</div>

You can see the html in action on this page: Superfood Picker Click on the "Compare" button on the front page. 您可以在此页面上看到html的运行情况: Superfood Picker单击首页上的“比较”按钮。

Based on the html alone I don't see why it doesn't work. 仅基于html我不明白为什么它不起作用。

Other relevant points: 其他相关要点:

1). 1)。 I have two modals on the same page. 我在同一页面上有两个模态。

2). 2)。 The other one works fine. 另一个工作正常。

3). 3)。 When I switch the ID of the dysfunctional modal to the ID of the modal that displays correctly that modal also displays correctly. 当我将功能异常模式的ID切换为正确显示的模式的ID时,该模式也将正确显示。

4). 4)。 The latter point would suggest to me that maybe it's the HTML that calls the modal that's the problem, but when I compare the two I don't see why one would work and the other wouldn't. 后一点向我暗示,也许是调用模式的HTML才是问题所在,但是当我将两者进行比较时,我看不出为什么一个会起作用而另一个却不起作用。

Here's the HTML for the second (functional) modal: 这是第二个(功能性)模式的HTML:

HTML (called through a jquery function) HTML(通过jquery函数调用)

$(".button-class").html("<div class='text-center'><ul class='list-inline'><li><button class='btn btn-success'><a href=" + state.greens[num].website + " target='_blank'>Company Website</a></button></li> <li><button class='btn btn-success' data-toggle='modal' data-target='#myModal'>View the Label</button></li></ul></div>");

I thought that maybe the two were interfering with one another, but if that was the case I'm not sure why the second one would work fine. 我以为这两个可能会互相干扰,但是如果是这种情况,我不确定第二个为什么会正常工作。

As mentioned above, the DIV with an ID of "part2" is display:none. 如上所述,ID为“ part2”的DIV显示为:none。 The modal is inside that DIV. 模态位于该DIV中。 You need to make that DIV display block for the modal to be visible. 您需要使该DIV显示块对模式可见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM