Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在javascript函数中显示引导模式?_Javascript_Jquery_Twitter Bootstrap_Modal Dialog - Fatal编程技术网

如何在javascript函数中显示引导模式?

如何在javascript函数中显示引导模式?,javascript,jquery,twitter-bootstrap,modal-dialog,Javascript,Jquery,Twitter Bootstrap,Modal Dialog,我的页面上有一个按钮,按下它会触发一些javascript函数,其中一个javascript函数会打开一个引导模式,但我似乎无法让它工作。这是我的密码。。。请帮忙 //elsewhere on the form is the button that triggers the javascript <a href="#" class="btn btn-danger" id="cancelPObtn" data-dismiss="modal">Yes, cancel it</

我的页面上有一个按钮,按下它会触发一些javascript函数,其中一个javascript函数会打开一个引导模式,但我似乎无法让它工作。这是我的密码。。。请帮忙

 //elsewhere on the form is the button that triggers the javascript
  <a href="#" class="btn btn-danger" id="cancelPObtn" data-dismiss="modal">Yes, cancel it</a>

 <!-- CANCEL A PO MODAL -->
 <div class="modal hide fade" id="error-dialog" style="display: none;">
   <div class="modal-header">
        <a class="close" data-dismiss="modal">x</a>
        <h3>Cancel Purchase Order?</h3>
   </div>
   <div class="modal-body">
   </div>
   <div class="modal-footer">
       <a href="#" class="btn btn-danger btn-modal btn-cancel"  data-dismiss="modal">Yes, cancel it</a>
       <a href="#" class="btn" data-dismiss="modal">Nevermind</a>
   </div>
 </div>




      $('.btn-danger').click(function(event) {
          if(some random conditional statement){
             //some stuff happens here
          }
          else{ 
                //Show form validation error modal-- I know this part is triggered but the modal will not show
                $("#error-dialog").modal("show");
          }
      });
//表单上的其他地方是触发javascript的按钮
$('.btn danger')。单击(函数(事件){
if(一些随机条件语句){
//这里发生了一些事情
}
否则{
//Show form validation error model——我知道这部分已触发,但该模式不会显示
$(“#错误对话框”).modal(“显示”);
}
});

您缺少了条件语句的
if(){
部分

很难看出您想用这部分代码做什么,但这里有一个基于您的工作代码:

$(“错误对话框”).modal(“显示”)


这是正确的方法,您的代码只是有一个错误。进入Chrome控制台并运行此命令,它就会工作。

我在输入问题时意外删除了if()。真正的解决方案是删除样式标记style=“display:none;”如果这不是你问题的真正问题,那么请不要接受这个答案。这只会让人们在阅读这个问题时感到困惑。