Change the asynchronous jQuery Dialog to be synchronous?

前端 未结 7 1395
名媛妹妹
名媛妹妹 2020-12-05 04:12

Currently, I\'m working to replace \"alert\'/\"confirm\" with the jquery dialog.

But most of legacy codes is written in some asynchronous way, which make it

7条回答
  •  情书的邮戳
    2020-12-05 05:00

    No, you can't do anything sync in Javascript (alert is breaking the rules, in fact). Javascript is built with "single threaded, async" in the core.

    What you can do, though, is disable functionality of the underlying page (lightbox-like) so no event get triggered from the page until you don't take the dialog action, be it OK or Cancel. Thought this does not help you to get your sync code working. You have to rewrite.

提交回复
热议问题