【发布时间】:2014-11-06 14:28:56
【问题描述】:
我已经搜索过这个问题。我按照这个问题的答案
Twitter Bootstrap modal blocks text input field
但是我的问题仍然存在。
这是我的模态 html
<div class="modal fade" style="display:none;" id="stockPerLocationModal" data-backdrop="static" ng-app="productInventory" ng-controller="ProductInventoryCtrl">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Stock per location</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<table class=" table responsive shopex-table table-hover no-margin">
<thead>
<tr>
<th>Outlet Name</th>
<th>Stock</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="val in outlets">
<td class="vcenter" ng-model="val.Name">
{{val.Name}}
</td>
<td>
<input type="text" class="form-control" value="{{val.Stock}}" ng-model="val.Stock">
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-red" id="btnSaveProductInventory" ng-click="updateProductInventory()">Save</button>
</div>
</div>
</div>
</div>
我在单击按钮时显示此模式。
这里是 JS:
function showStockPerLocationModal() {
// $("html, body").animate({ scrollTop: 0 }, "fast");
$('#stockPerLocationModal').modal('show');
}
我按照答案中的描述添加了事件:
$('#stockPerLocationModal').on('shown.bs.modal', function () {
$(document).off('focusin.modal');
});
但是,当模式打开时,我无法在输入字段中输入文本。
如果我将窗口滚动到顶部。它会起作用的。
所以我在这个函数showStockPerLocationModal中打开模态之前添加了这行代码。
$("html, body").animate({ scrollTop: 0 }, "fast");
页面滚动后 twitter bootstrap 3 modal 阻止输入字段的任何原因?
谢谢。
【问题讨论】:
-
您可以使用这个小提琴来重现您的问题:jsfiddle.net/robertrozas/540bcohh
-
它在那里工作。由于没有滚动到底部发生。
-
既然你用的是Angular,那就用angular-ui.github.io/bootstrap
标签: jquery twitter-bootstrap-3 modal-dialog