我正在使用DirtyForms和$.blockUI插件,后者在单击链接时更改页面(在我的应用程序中,某些页面需要几秒钟才能加载,并且视觉反馈很好)。
当我更改字段内容然后单击任何链接时,会触发 DirtyForms:但是当我取消停留在页面上的过程时,$.blockUI
开始其游戏,导致页面卡住
$('form[method="post"]').dirtyForms();
$('a').on('click', function(){
$.blockUI();
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.dirtyforms/2.0.0/jquery.dirtyforms.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.70/jquery.blockUI.min.js"></script>
<p>Change the field content to activate DirtyForms, then click on the link.<br>
When the popup appears, click on "cancel" to stay on the page.<br>
Watch blockUI getting fired as the link is going to be followed</p>
<form action="#" method="post">
<input type="text" name="username" required>
<button type="submit">send</button>
</form>
<a href="https://google.com">click me after changing field content</a>
请问,有什么解决办法吗?
编辑:我也尝试了stay.dirtyforms
和afterstay.dirtyforms
事件,但它们没有效果。defer.dirtyforms
似乎有效,但事件被触发了两次(我放了一个console.log()
检查),我不确定这是要走的路......