Tuesday, October 23, 2012

JQuery - BlockUI for Process loading Image

Steps to run Block UI:

Step 1: Copy and add the jquery.blockUI.js in project from the below code
Step 2: Add $.blockUI() to start loading image & $.unblockUI() to stop loading image

Note: We can modify the jquery.blockUI to add our custom messages

What is jQuery BlockUI?

The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAXwithout locking the browser[*]. When activated, it will prevent user activity with the page (or part of the page) until it is deactivated. BlockUI adds elements to the DOM to give it both the appearance and behavior of blocking user interaction.
Usage is very simple; to block user activity for the page:
$.blockUI();
Blocking with a custom message:
$.blockUI({ message: '<h1><img src="busy.gif" /> Just a moment...</h1>' });
Blocking with custom style:
$.blockUI({ css: { backgroundColor: '#f00', color: '#fff'} });
To unblock the page:
$.unblockUI();
If you want to use the default settings and have the UI blocked for all ajax requests, it's as easy as this:
$(document).ajaxStart($.blockUI).ajaxStop($.unblockUI);

No comments:

Post a Comment