简体   繁体   English

如何始终显示 Bootstrap 3 模式?

[英]How to always display Bootstrap 3 modal?

Bootstrap 3 modals are hidden by default. Bootstrap 3 模式默认是隐藏的。 To launch them I have to click a trigger button:要启动它们,我必须单击触发按钮:

<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
  Launch demo modal
</button>

JSFiddle JSFiddle

I have tried the following but it has no effect:我尝试了以下但没有效果:

jQuery(window).load(function(){
    jQuery('#myModal').modal('show');
});

How can I ensure my modal is always displayed on screen?如何确保我的模态始终显示在屏幕上? ie I don't want the user to have to manually display it by clicking on the trigger button.即我不希望用户必须通过单击触发按钮来手动显示它。 I don't want them to be able to close it either.我也不希望他们能够关闭它。 I'd like it to remain open at all times.我希望它一直保持开放。

Everything you asked is perfectly described in the docs .你问的一切都在文档中得到了完美的描述。

Displayed on screen显示在屏幕上

Shows the modal when initialized.初始化时显示模态。

$("#my-modal").modal({ show : true });

I don't want them to be able to close it either我也不希望他们能够关闭它

Closes the modal when escape key is pressed And Includes a modal-backdrop element.当按下转义键时关闭模态并包括模态背景元素。 Alternatively, specify static for a backdrop which doesn't close the modal on click.或者,为不会在单击时关闭模态的背景指定静态。

$("#my-modal").modal({
    backdrop : "static",
    keyboard: false
});

Here is the updated fiddle where users can't close the model but you need to remove the html elements for close buttons cuz thats very evil for your users :P这是更新的小提琴,用户无法关闭模型,但您需要删除关闭按钮的 html 元素,因为这对您的用户非常不利:P

jQuery(window).load(function(){
    jQuery('#myModal').modal('show').on('hide.bs.modal', function(e){
      e.preventDefault();
    });
});

http://jsfiddle.net/95Vf7/2/ http://jsfiddle.net/95Vf7/2/

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

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