Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery block UI when ajax starts

I am trying to show blockui when ajax starts like so:

 // block when ajax activity starts
    $(document).ajaxStart($.blockUI({ message: '<h1><img src="busy.gif" /> Just a moment...</h1>' }));

and then I want to stop it doing

 // unblock when ajax activity stops 
    $(document).ajaxStop($.unblockUI); 

Problem Is that it won't load when ajax is performed what have I done wrong'??

like image 202
user342391 Avatar asked Jun 15 '10 18:06

user342391


1 Answers

I think you need to change it like so:

$(document).ajaxStart(function () {
  $.blockUI({ message: '<h1><img src="busy.gif" /> Just a moment...</h1>' });
});

When you need to pass parameters to the function you want to bind you should use an anonymous function and then call your method inside it. $.blockUI() returns something which is not callable, so it doesn't work to bind it that way.

like image 60
g.d.d.c Avatar answered Nov 05 '22 21:11

g.d.d.c