I know this is very old, but there is a situation when the accepted answer does not work.
If the selectmenu z-index was changed to a higher value using CSS, the option list will remain behind the dialog (at least in my case) even if the above remedy is called. In my case, there is a requirement for increasing the z-index of all ui-dialogs due to application conflicts.
There are two alternatives to fix this (in this example, the z-index for all dialogs was set to z-index: 750 using CSS):
Using JQuery:
$('#selectmenu-menu').parent().css('z-index', '751');
Using CSS / the Classes option when initializing the specific selectmenu
CSS
.maxz {
z-index: 751;
}
JavaScript
$('#selectmenu').selectmenu({
classes: {
"ui-selectmenu-open": "maxz"
}
})
What is happening:
- The z-index for the .ui-dialog is set through CSS (the number may vary per your application, but you get the gist of if). In this example I'll use 750.
- When a selectmenu element is created, the "options" are created in an unordered list. That list has an id of the original select menu, appended with "-menu".
- In order to bring the list above the dialog, you have to change the z-index of the list's wrapper element to at least 751, changing the z-index of the unordered list has no effect.
- In the first example, we address the list's wrapper element (its parent), bringing it 1 index higher than the dialog and thus to the top.
- In the second example the CSS takes care of the problem itself. We simply create a CSS class with a z-index with a value 1 higher than the dialog z-index that was set, and then use the 'classes' option in the selectmenu initialization to assign that class to the 'ui-selectmenu-open' (the class that is added to the ui-selectmenu-menu wrapper element when the button is clicked and the menu opens).
Alternative #1
In the first example, the above must be included after the selectmenu is initialized.
$('#menu1').selectmenu({
*setup and functions added here*
});
$('#menu1-menu').parent().css('z-index', '751');
Note that for me, at least, trying to include the code in the create event for the affected selectmenu has no effect, it must be called separate and after the menu initialization.
Alternative #2
The second example is more efficient
You simply set the z-index value for .maxz to the highest z-index set for all the dialogs + 1. (Not sure that I would understand a reason for having 5 different dialogs with 5 different z-indices, but anything is possible.)
If there are multiple selectmenus that you need to initialize with this process and all share the same events just group these by class and initialize them by class instead of id, adding the above classes option.
However, if you have mulitiple selectmenus, each with different setup properties (i.e., classes, functions, etc.), you could add the classes to each as above, or you could add a class to each select menu, such as "s-max-z", and then execute the following after all have been initialized:
$('.s-max-z').selectmenu("option", "classes.ui-selectmenu-open", "maxz");
Notes:
Using the classes option when initializing the dialog widget (while using modal: true) to return the z-index to default and then using the accepted answer did work, almost. The z-index for the selectmenu was correctly reset and it opened above the dialog, the problem was that you can't get to the dialog to do anything!
CSS
.minz {
z-index: initial;
}
JavaScript
$('#dialog').dialog({
modal: true,
classes: {
"ui-dialog": "minz"
}
})
What occurred was the dialog was opened behind the widget-overlay, which still had the original z-index - 1 (in my case 749) set initially for the dialogs in CSS.
Because the widget-overlay is created once and appended to the end of the body, it is not possible without a lot of extra CSS / JavaScript to keep resetting the widget-overlay's z-index for each dialog that appears.
Even with one single dialog, the CSS for the widget-overly has to be set separately (I tried it in the classes for the dialog with no affect).