twitter-bootstrap yii2 bootstrap 模式隐藏显示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29844430/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
yii2 bootstrap modal hide show
提问by Vikram Pote
I am using yii2 bootstrap model to show some data on that and bootstrap model is close through two ways,
我正在使用 yii2 bootstrap 模型来显示一些数据,并且 bootstrap 模型通过两种方式接近,
1)on click of model close button.
1)点击模型关闭按钮。
2)on click of that black area which is appeared in background like light-box.
2)点击出现在背景中的黑色区域,如灯箱。
I already handle the close button event but unable to handle that black area click event. I don't want to close my model while click on that black area how should i do that.Please help me. Thanks in advance.
我已经处理了关闭按钮事件,但无法处理那个黑色区域点击事件。我不想在点击那个黑色区域时关闭我的模型我应该怎么做。请帮助我。提前致谢。
My model
我的模型
<?php
Modal::begin([
'header' => 'Student Info',
'id' => 'stud-info',
'closeButton' => ['id' => 'close-button'],
]);
$form->field($model, 'StudName',
[
'options'=>['enableAjaxValidation' => false]
])->textInput();
Modal::end();
采纳答案by arogachev
For preventing closing when clicking on black area use:
为了防止点击黑色区域时关闭,请使用:
'backdrop' => 'static',
There is another way of closing - by clicking Escbutton. It can be prevented like that:
还有另一种关闭方式 - 通过单击Esc按钮。可以这样预防:
'keyboard' => false,
You should put these options under clientOptionssection like that:
您应该将这些选项放在clientOptions部分下,如下所示:
'clientOptions' => [
...
],
See this related questionfor details.
有关详细信息,请参阅此相关问题。
No need to write additional javascript for events to achieve that.
无需为事件编写额外的 javascript 即可实现。

