按下输入在子模式对话框上输入父模态对话框(ie11和边缘)
问题描述:
我有两个引导模态对话窗口,一个创建另一个。当在孩子的文本输入上按下回车键时,它也会触发父母上的事件。最后一个关注父母的按钮是创建孩子的按钮,这会导致孩子立即被重新创建。按下输入在子模式对话框上输入父模态对话框(ie11和边缘)
我发现一些类似的问题,其状态确保对话框上的确定按钮是类型=按钮,因为它们默认提交。我确定按钮具有按钮的类型,但问题仍然存在,虽然它在Chrome中工作正常。
这里是plunker中发生的一个例子。 这是第一个模态窗口。
<script type="text/ng-template" id="myModalContent.html">
<div class="modal-body">
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="button" ng-click="shownewwindow()">New Modal</button>
<button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
</div>
</script>
这是第二个。
<script type="text/ng-template" id="modal2.html">
<div class="modal-body">
<input type=textarea value="test" ng-keypress="keydown($event)" autofocus></input>
</div>
<div class="modal-footer">
<button class="btn btn-default" type="button" ng-click="ok()">ok</button>
<button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
</div>
</script>
这里是ok,cancel和keydown的函数。
$scope.ok = function() {
console.log("ok");
$uibModalInstance.dismiss({completed: true});
};
$scope.cancel = function() {
$uibModalInstance.dismiss('cancel');
};
$scope.keydown = function(event) {
var enterKeyCode = 13;
$uibModalInstance.dismiss({completed: true});
}
如何防止儿童被按下时,输入被重复创建任何想法,将不胜感激,谢谢。
答
尝试禁用按钮,当你点击它。
<button ng-disabled="aScopeVar" ng-click="setAScopeVarToTrue()">My button</button>
不要忘记在创建子项后将aScopeVar
设置为true。
你需要发布你的代码给任何人能够给你任何形式的答案。 –
我的歉意,这里是一个例子[plunker](http://plnkr.co/edit/smeHL3jXB64vLrIkGeTZ?p=preview)是怎么回事。在进行这个例子的进一步检查时,我发现Enter键实际上来自孩子上的输入字段。 –