user918064
user918064

Reputation: 145

Jquery ajaxStart and blockUI

Using Asp.Net MVC 3 (Razor). I'm trying to add the blockUI plug in to show loading indicator when calling actions with @Ajax.ActionLink

It works fine if I use the default call of

$(document).ajaxStart($.blockUI);

But when I try to customize the message using the following, the UI is blocked as soon as the page loads. Can someone advise the correct format?

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

Upvotes: 3

Views: 3668

Answers (3)

Didier Ghys
Didier Ghys

Reputation: 30666

In the second piece of code, you are actually executing the blockUI method.

Wrap it in an anonymous function:

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

Working example on jsfiddle

Upvotes: 5

Abhishek
Abhishek

Reputation: 91

include the jquery js file and the blockUI js file, and then execute the code

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

Upvotes: 0

Mbrevda
Mbrevda

Reputation: 3080

Wrap the blockui stuff in a function:

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

Upvotes: 1

Related Questions