QuickTip: Styling jqModal with blockUI and AJAX requests
This is just a quick tip how to style a jqModal window when we are loading contents via AJAX. There are two possibilites:
- use ajaxText, but this sometimes is not handy if you have complex styled content from AJAX
- use blockUI and style the jqModal to show only after the AJAX has been loaded.
My idea is to block the user interface with a “Please wait…” message and then to slide down nicely the jqModal and unblock the page. So, firstly, we add the styles to jqModal dialog:
$('.dialog').jqm(
ajax: '@href',
modal: true,
target: '#target',
onLoad: function(h){
h.w.css('opacity',0.8).slideDown();
},
onHide: function(h) {
h.w.slideUp('slow');
h.o.remove();
}
);
Now we have a nice animated jqModal. Next, we are adding blocking behavior:
$('.dialog').jqm(
ajax: '@href',
modal: true,
target: '#target',
onShow: function(h){
$.blockUI({ css: {
border: 'none',
padding: '15px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: '.5',
color: '#fff'
} });
},
onLoad: function(h){
h.w.css('opacity',0.8).slideDown();
$.unblockUI();
},
onHide: function(h) {
h.w.slideUp('slow');
h.o.remove();
}
);
Et Voila, you’re done! Hopefully somebody will find this useful.
Thanks, this blog helped me somewhat in solving some issues with the latest version, Why do they always leave out vital information when they upgrade? It may be trivial to them but not for us! I’m sure i’m not alone.
Do you have a working example of this?
I wish I knew how to even implement what you’ve done. I’m looking for a cross browser styling solution for jqModal. I’m more of a graphic designer than front end developer, so my programming skills are limited.
I have a few nice examples that are very close. In one case I can’t get the CSS3 rounded corners to render through jqModal in any IE. The other issue is png border images not rendering in IE either.
Found your website on Yahoo. Pinged it to my list of subscribers.