Below is a simple example to implement this workaround to a jQuery UI dialog. This works equally well for both modal and non-modal dialogs.
$(function(){ $('#dialog_1').dialog({ autoOpen: false, create: function( event ){ // set dialog's parent position to 'fixed' under the create event $( event.target ).parent().css( 'position', 'fixed' ); } }); $('#btn_1').click(function(){ // to reposition the dialog to the center when re-opened $('#dialog_1').dialog( 'option', 'position', 'center' ); $('#dialog_1').dialog( 'open' ); }); });
Hopefully, this workaround will provide better user experience on top of all the great features in jQuery UI library.
2 comments:
Awesome, this fixes the issue. Just one thing, there is a colon that should be replaced by a comma on this line:
$( event.target ).parent().css( 'position': 'fixed' );
I should have mentioned "Thanks" much earlier for your catching the syntax error. Yes, the error has been corrected in the above. Thanks again!
Post a Comment