SHARE
TWEET

Untitled

a guest Jun 19th, 2017 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Helper for registerin ajax callbacks.
  3.  * This plugin is dependent on jquery.namespace
  4.  */
  5. (function($) {
  6.     $.wicket = {
  7.       /**
  8.        * Register a callback function to be executed after wicket ajax call is complete.
  9.        * @return reference to passed function.
  10.        */  
  11.       ajaxCallback : function(fn) {
  12.       this.registerCallbacks({
  13.         onSuccess: fn,
  14.         onFilure: fn
  15.       });
  16.       return fn;
  17.     },       
  18.       registerCallbacks: function(arg) {
  19.         if ($.namespaceExist('Wicket.Ajax')) {
  20.           if (arg.onBefore) {
  21.           Wicket.Ajax.registerPreCallHandler(arg.onBefore);
  22.         }
  23.         if (arg.onSuccess) {
  24.           Wicket.Ajax.registerPostCallHandler(arg.onSuccess);
  25.         }
  26.         if (arg.onFailure) {
  27.           Wicket.Ajax.registerFailureHandler(arg.onFailure);
  28.         }
  29.         }
  30.       }
  31.     }
  32. })(jQuery);
RAW Paste Data
Want to get better at JavaScript?
Learn to code JavaScript in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top