blockui over jQueryUI modal dialog

Thanks Didier for your answer, it helped get me on track. You'll notice that the jsfiddle in Didier's answer works the first time you open the dialog but any further open and ajax results in the blockUI elements appearing beneath the dialog. The dialog must recalibrate it's z-index to be the top dog every time it opens.

I've found two possible ways around this:

  1. 'destroy' the dialog when it is closed and recreate it when it is opened.
  2. rather than blocking the whole UI, just block the dialog. This can be done using the widget method, like this:

    $( ".selector" ).dialog( "widget" ).block({ 
        theme: false,
        message: '<h1>Wait for me please...</h1>', 
        css: { border: '3px solid #a00' } 
    });
    

You don't specify what you have tried with z-index.

The blockUI plugin has an option to change the z-index of the message it creates (documentation):

// z-index for the blocking overlay 
baseZ: 1000,

jQuery UI Dialog as an option for specifying a z-index as well. Its default value is 1000. So you have to set a higher number for the BlockUI option, let's say 2000:

$.blockUI({
    theme: true,
    baseZ: 2000
})

DEMO