How to create a custom “confirm” & pause js execution until user clicks button?

前端 未结 6 897
后悔当初
后悔当初 2020-12-11 01:37

Ok, I\'m doing a bunch of RIA/AJAX stuff and need to create a \"pretty\", custom confirm box which is a DIV (not the built-in javascript confirm). I\'m having trouble determ

6条回答
  •  一整个雨季
    2020-12-11 02:28

    In my case, the goal was to display a customConfirm box whenever user clicks the delete link embedded within each row of a .Net Repeater

    Whenever user clicks the delete link of any particular row,the Custom Confirm function is called. Now inside the confirm function, in addition to rendering the new box, the following 2 things needed to be done:

    // obtain the element(we will call it targetObject) that triggered the event
    
    targetObject = (event.target==undefined ? event.srcElement : event.target);
    
    // include a call to _doPostBack in the onclick event of OK/YES button ONLY
    
    (targetObject.href!=undefined){ eval(targetObject.href); } else{ _doPostBack(targetObject.name,''); // it is assumed that name is available
    

    The above if/else construct pertains to my case. Main thing is to just know that you can simulate the confirm pause & continuity using the event object and __doPostBack function.

提交回复
热议问题