andruhon commented on a change in pull request #384: WICKET-6703 replace eval 
with jQuery.globalEval; add suspend/notify
URL: https://github.com/apache/wicket/pull/384#discussion_r331840246
 
 

 ##########
 File path: 
wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
 ##########
 @@ -350,6 +350,44 @@
         */
        Wicket.Ajax.Call = Wicket.Class.create();
 
+       Wicket.Ajax.Call._suspended = 0;
+
+       Wicket.Ajax.Call.currentNotify = undefined;
+
+       Wicket.Ajax.Call.suspend = function () {
+               if (typeof (Wicket.Ajax.Call.currentNotify) != "function") {
+                       Wicket.Log.error("Can't suspend: no evaluation in 
process");
+                       return;
+               }
+               Wicket.Ajax.Call._suspended++;
+               var notify = Wicket.Ajax.Call.currentNotify;
+               var released = false;
+
+               return function () {
+                       // release only once
+                       if (released === false) {
+                               released = true;
 
 Review comment:
   Every notify returned should be called, for example this one works:
   
   ```
   function myHideFunction(id) {
     var notify1 = Wicket.Ajax.Call.suspend();
     var notify = Wicket.Ajax.Call.suspend();
     $("#"+id).fadeOut(3500, function(){
       console.log("fade out done");
       notify();
       notify1();
     });
     otherSuspendingFunction();
   }
   
   function otherSuspendingFunction() {
     var notify = Wicket.Ajax.Call.suspend();
     setTimeout(function () {
       console.log("otherSuspendingFunction done");
       notify(); // attempts to notify before the fadeOut finished
     }, 1000);
   }
   ```
   But if you any of these three notifys will get lost the stuff will get stuck.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to