blockUi unblock all elements blocked

636 views Asked by At

I use this plugin (http://malsup.com/jquery/block/) to show some loading effects for my ajax call using jQuery.

I defined a global ajax error handling :

$( document ).ajaxError(function( event, request, settings ) {
    toastr['error']('error happened on this url: '+ settings.url);
    $.unblockUI();
});

But the fact is I block elements, not global page, like :

$('form').submit(function(e) {
     e.preventDefault();
     $(this).block();

     // my ajax call with error
     $.post('.....');
}

So is there any way to unblock all elements blocked ? $.unblockUI(); is only unblocking the page, not all elements being blocked before.

1

There are 1 answers

0
Vincent Decaux On

Ok, the easiest way I found for now is :

 $('.blockUI').each(function() {
      // .block() appends a .blockUI element, just unblock the parent
      $(this).parent().unblock();
 });

Seems to work.