I am trying to re-order the z-indexes of several DIVs so that the most recently dragged stays topmost.
I have the following code:
$(".elementsIWantToDrag").draggable({
zIndex: 10000,
stop: function(){
$(this).css('z-index', 9999);
alert($(this).css('z-index'));
}
});
...and all is well and good until the actual execution. When I mouse-up after dragging an item, sure enough I get the alert with 9999 as the z-index value. Immediately after I click "OK" to clear the alert box, FireBug shows the value being changed to 10.
It appears to me that the stop() event is being called before the draggable code is actually finished doing everything... like setting the z-index back to what it was before the dragging started.
Removing the zIndex: 10000
seems to have a slightly different effect - draggable assigns different numbers to the z-indexes than with that parameter, but it is still overriding what I'm trying to do.
Suggestions on how to get this to work?