I came across this post on the boards concerning using the jQuery BlockUI plugin, which was handy because I hadn’t had any exposure to the plugin previously. BlockUI is very handy way of controlling your interface to avoid unwanted user behavior. For instance, if you’re sending a JavaScript Remoting call over the wire which might take a decent amount of time to process on the Apex side, you could use BlockUI to grey out the page and display a message like this:
Here’s some baseline code which would show a brief message like that one when quicksaving a record:
1<apex:page standardController="Contact">
2 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"/>
3 <script src="https://ajax.microsoft.com/ajax/jquery.ui/1.8.5/jquery-ui.js"/>
4 <script src="http://malsup.github.com/jquery.blockUI.js" />
5 <link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/base/jquery-ui.css" />
6
7 <script>
8 j$ = jQuery.noConflict();
9
10 function blockme() {
11 j$.blockUI({ css: {
12 border: 'none',
13 padding: '15px',
14 backgroundColor: '#000',
15 '-webkit-border-radius': '10px',
16 '-moz-border-radius': '10px',
17 opacity: .5,
18 color: '#fff'
19 } });
20
21 }
22 </script>
23 <apex:form >
24 <apex:commandButton onclick="blockme()" oncomplete="j$.unblockUI();" value="Save!" action="{!quickSave}" />
25 </apex:form>
26</apex:page>I would recommend downloading the plugin and serving it from a static resource, however, to avoid any “non-secure content on a secure page” type browser warning. BlockUI has a lot of different options to it and several templates of displaying error messages. Let us know how you might use it for your project.
