Bootstrap 模态对话框在按下退出键时关闭
Bootstrap model dialog closes on hitting the escape key
我正在使用 Bootstrap 和 Angular 构建模型对话框,我不想在按下 esc 键时关闭模型。现在,当按下转义键时,我的模型正在关闭。
var modalInstance = $modal.open({
backdrop: 'static',
Keyboard: false,
templateUrl: 'userprofile.html',
controller: 'UserProfileController'
});
<div class="container" style="overflow: auto;width:750px;height:500px">
<div class="userProfile">
<form name="userForm" ng-submit="submitForm(userForm.$valid)" novalidate>
<div class="row-flow">
<!-- First NAME -->
<div class="form-group-profile col-sm-6 required"
ng-class="{ 'has-error' : userForm.firstName.$invalid && !userForm.firstName.$pristine }">
<label class="form-control-label">FIRST NAME</label>
<input type="text" name="firstName" class="form-control" ng-model="firstName"
required>
<p ng-show="userForm.firstName.$invalid && !userForm.firstName.$pristine"
class="help-block">First name is required</p>
</div>
<!-- Last NAME -->
<div class="form-group-profile col-sm-6 required"
ng-class="{ 'has-error' : userForm.lastName.$invalid && !userForm.lastName.$pristine }">
<label class="form-control-label">LAST NAME</label>
<input type="text" name="lastName" class="form-control" ng-model="lastName"
required>
<p ng-show="userForm.lastName.$invalid && !userForm.lastName.$pristine"
class="help-block">Last name is required</p>
</div>
</div>
</form>
</div>
</div>
问题出在您的设置上。你有 Keyboard
而不是 keyboard
.
$(document).ready(function () {
$('.modal').each(function () {
$(this).modal({
keyboard: false,
show: false
})
});
});
我 运行 上面的代码在所有 bootstrap 模式上禁用键盘。但是我没有使用 angular。 keyboard 属性 看起来全是小写。试试改成全小写看看有没有区别?
我正在使用 Bootstrap 和 Angular 构建模型对话框,我不想在按下 esc 键时关闭模型。现在,当按下转义键时,我的模型正在关闭。
var modalInstance = $modal.open({
backdrop: 'static',
Keyboard: false,
templateUrl: 'userprofile.html',
controller: 'UserProfileController'
});
<div class="container" style="overflow: auto;width:750px;height:500px">
<div class="userProfile">
<form name="userForm" ng-submit="submitForm(userForm.$valid)" novalidate>
<div class="row-flow">
<!-- First NAME -->
<div class="form-group-profile col-sm-6 required"
ng-class="{ 'has-error' : userForm.firstName.$invalid && !userForm.firstName.$pristine }">
<label class="form-control-label">FIRST NAME</label>
<input type="text" name="firstName" class="form-control" ng-model="firstName"
required>
<p ng-show="userForm.firstName.$invalid && !userForm.firstName.$pristine"
class="help-block">First name is required</p>
</div>
<!-- Last NAME -->
<div class="form-group-profile col-sm-6 required"
ng-class="{ 'has-error' : userForm.lastName.$invalid && !userForm.lastName.$pristine }">
<label class="form-control-label">LAST NAME</label>
<input type="text" name="lastName" class="form-control" ng-model="lastName"
required>
<p ng-show="userForm.lastName.$invalid && !userForm.lastName.$pristine"
class="help-block">Last name is required</p>
</div>
</div>
</form>
</div>
</div>
问题出在您的设置上。你有 Keyboard
而不是 keyboard
.
$(document).ready(function () {
$('.modal').each(function () {
$(this).modal({
keyboard: false,
show: false
})
});
});
我 运行 上面的代码在所有 bootstrap 模式上禁用键盘。但是我没有使用 angular。 keyboard 属性 看起来全是小写。试试改成全小写看看有没有区别?