2016-07-28 87 views
0

我使用的模式,我从一个以前的网站,它使用正常。区别在于这种模式只会在IE9中出现,才能将用户引导至更好的浏览器。我能够用一个警报来测试它,并且工作正常。Bootstrap模式没有响应

但是,由于某些原因,当我将以前的网站所做的代码传输到此新网站时,Modal未响应,并且网站上未显示某一点。

当我尝试关闭“关闭”按钮时,它只会刷新页面。我不知道为什么当我关闭“X”按钮时,它也不起作用。

该代码被插入到Coldfusion文件中,我不确定它是否会导致冲突。

任何帮助,将不胜感激。

这是我为模态所做的。即只检测是否是IE9与否:

<!---<div class="ie-only" style="overflow-y:hidden;"> 
     <div class="modal fade in" id="myModal" aria-hidden="false" style="display:block; padding-right:17px;"> 
      <div class="modal-dialog modal-md custom-height-modal"> 
       <div class="modal-content"> 
        <div class="modal-header" style="background-color:##428bca"> 
         <button type="button" class="close" data-miss="modal">x</button> 
         <h3 class="modal-header" style="background-color:##428bca; text-align:center">Attention</h3>       
        </div><!---Modal-Header Div---> 
        <div class="modal-body"> 
         <p style="text-align:center">You are using an outdated browser.<br /> <br /> <a href="http://browsehappy.com/">Upgrade your browser today</a> to better experience this site.</p> 
        </div><!---Modal-Body Div---> 
        <div class="modal-footer"> 
         <p class="text-center"><a class="btn btn-default" data-dismiss="modal">Close</a></p> 
        </div><!---Modal-Footer Div---> 
       </div><!---Modal-Content Div---> 
      </div><!---Custom Height Div---> 
     </div><!---Modal Fade in Div---> 
    </div><!---Start of Modal Div--->    
    <!--End of Modal container--> ---> 
    <!---<script> 
      $(function(){ 
       $('##myModal').modal('show'); 
      } 
      </script> 
       <div class="modal-backdrop fade in"></div>---> 

回答

2

它看起来像有在你的代码语法问题:

$(function(){ 
    $('##myModal').modal('show'); 
} 

这是不正确;它应该是:

$(function(){ 
    $('#myModal').modal('show'); 
}); 

将模态载荷更正为模态时,这反过来导致关闭按钮按预期运行。缺少这个模式仍然会加载(因为你已经激活了in),但是加载时没有覆盖,并且缺少Bootstrap的Modal JS的钩子,这就解释了为什么你的关闭按钮不起作用。

您可以在这里看到的功能例如:为什么你的代码是不是在你的模态div工作

inhttp://www.bootply.com/24IPYP8O3F

指示引导,以使该模式可见,并根据其位置Bootstrap CSS。尽管你的jQuery是错误的,所以Bootstrap把它看作只是文档一部分的HTML。

一旦您更正了jQuery Bootstrap的处理过程,作为Modal Javascript组件。一旦发生这种情况,它会显示覆盖图(默认情况下),并且data-dismiss属性会被正确处理。

它的缺点是,为什么你的Modal没有像Modal那样表现的整个问题是你的jQuery是错误的。

+0

是的,但由于某种原因在Coldfusion中,它不喜欢'#',当我放上'##'时,模态出现,但是功能已关闭。另外,你在谈论下面的js文件:bootstrap.js和bootstrap.min.js?如果是的话,他们被称为。另外,模态仍然加载?你是什​​么意思 –

+0

这里是小提琴https://jsfiddle.net/robontrix/jn2s61t3/1/#&togetherjs=IsMTPVcwfn –

+0

我会详细说明为什么它不是暂时工作。我还添加了模态正确运行的Bootply示例。 –