Yii2 Bootstrap Modal背景不起作用

时间:2015-06-16 03:58:40

标签: javascript jquery twitter-bootstrap yii2

我使用Yii2 bootstrap Modal创建了模态窗口。 Modal的默认行为是,如果在模态区域外单击,模态将自动关闭。我想防止这种行为意味着在单击模态外部时不应该关闭模态窗口。

以下是我的Yii2模态代码:

$autoload['libraries'] = array('database', 'session','your_librery_name');

正如twitter bootstrap网站中所提到的,我在JQuery模式选项中添加了<?php Modal::begin([ 'header' => '<h4>Disapprove Request</h4>', 'id' => 'disapproveModal', 'size' => 'modal-lg', 'class' => 'bg-gray', ]); ?> <div class="showmsg" style="display: none;"></div> <div class="control-group"> <label>Please select the reason of disapproval. Click on "Disapprove" to proceed and click on "Cancel" to remove dialog</label> <input type="text" name="disappr_txt" id="disappr_text" class="form-control" placeholder="Enter reason of disapproval" required> </div> <br/> <?= Html::submitButton('Disapprove', ['class' => 'disapprovebtn btn btn-primary', 'value' => 'disapprove', 'name' => 'submit']); ?> <?= Html::a('Close', 'javascript:void(0);', ['class' => 'btn btn-primary closebutton', 'aria-hidden' => "true", 'data-dismiss' => "modal"]) ?> <?php Modal::end(); ?> backdrop=>static,但它仍无法正常工作,并且在单击模态区域外部后模态将被关闭。

以下是我的JQuery代码:

keyboard=>false

2 个答案:

答案 0 :(得分:5)

我也遇到过这个问题。我能够使用代码

解决该问题
'clientOptions' => ['backdrop' => 'static', 'keyboard' => false] 
Modal:begin()中的

答案 1 :(得分:0)

<?php
Modal::begin([
    'header' => '<h4>Disapprove Request</h4>',
    'id' => 'disapproveModal',
    'size' => 'modal-lg',
    'class' => 'bg-gray', 
    'clientOptions' => ['backdrop' => 'static', 'keyboard' => false],
]);
?>

根据Win Naung在Modal中的回答添加clientOptions