遇到一个奇怪的问题,我正在开发一个仅使用 Firefox 的 angularJS 应用程序,但如果用户单击 Close
按钮,我会遇到模态工具提示的问题。
当模式打开时,有一个下拉列表,默认情况下它是空白的,也是必需的。该模式还有一个 Submit
按钮和 Close
按钮。在完成所有必填字段之前,提交
按钮处于禁用状态,并且关闭
按钮始终处于启用状态。
如果您在没有选择选项(这是一个有效操作)的情况下单击 Close
按钮,模态将按预期关闭,但会显示所需的工具提示。
有人知道这个问题的解决方案吗?
最佳答案
由于示例代码不存在,根据您的问题,我尝试了使用“提交”和“关闭”按钮的解决方案。
无论您点击哪个按钮,都会触发提交功能。因此,您需要使用 $event.preventDefault();
示例 HTML
<form name="form" novalidate ng-submit="saveModal()">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<button class="btn btn-success" type="submit">
<span>Submit</span>
</button>
<button class="btn btn-default" ng-click="closeModal($event)">
<span>Close</span>
</button>
</div>
</div>
</form>
示例 Controller
$scope.closeModal= function ($event) {
$event.preventDefault();
// Close modal related codes here
};
$scope.saveModal = function() {
// I assume that the required tooltip related codes are available
// inside the submit's function
};
关于javascript - 在 FireFox 中关闭模态时显示的必需工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29847617/