Custom “confirm” dialog in JavaScript?

前端 未结 7 1064
悲&欢浪女
悲&欢浪女 2020-12-01 06:33

I\'ve been working on an ASP.net project that uses custom \'modal dialogs\'. I use scare quotes here because I understand that the \'modal dialog\' is simply a div in my ht

7条回答
  •  时光说笑
    2020-12-01 06:59

    Faced with the same problem, I was able to solve it using only vanilla JS, but in an ugly way. To be more accurate, in a non-procedural way. I removed all my function parameters and return values and replaced them with global variables, and now the functions only serve as containers for lines of code - they're no longer logical units.

    In my case, I also had the added complication of needing many confirmations (as a parser works through a text). My solution was to put everything up to the first confirmation in a JS function that ends by painting my custom popup on the screen, and then terminating.

    Then the buttons in my popup call another function that uses the answer and then continues working (parsing) as usual up to the next confirmation, when it again paints the screen and then terminates. This second function is called as often as needed.

    Both functions also recognize when the work is done - they do a little cleanup and then finish for good. The result is that I have complete control of the popups; the price I paid is in elegance.

提交回复
热议问题