问题
in FF and Internet Explorer the dialog box shws up in the center, but in chrome it ends up on the left side.
How can i fix this?
code (self
is the object this is in):
$('form').live('submit',function(e){
e.preventDefault();
var $this = this;
console.log('click submit')
$('<div>',
{html: 'Are you sure you want to submit this table?<br/> All undo information will be lost.'})
.dialog({
modal: true,
title: 'Are You Sure?',
buttons: {
ok: function(){
$.get($this.action,$($this).serialize()+'&page='+self.pageOn,function(data){
console.log(data);
self.pageChanged = false;
self.origPage = $('#page').clone();
self.lastClick = $('#page').clone();
})
$(this).dialog('close');
},
cancel: function(){
$(this).dialog('close');
}
},
beforeClose: function(){
$(this).remove();
}
})
return false;
})
回答1:
Perhaps assign a class to the dialog's div e.g:
$('<div class="ui-dialogue">',
{html: 'Are you sure you want to submit this table?<br/> All undo information will be lost.'})
.dialog({
modal: true,
title: 'Are You Sure?',
buttons: {
And then create include a css rule that will center the dialogue on the page like so:
.ui-dialogue{margin:0 auto;}
Or somesuch css that will center the dialogue... It's a guess, but might force it to work on most browsers.
来源:https://stackoverflow.com/questions/5639360/jquery-dialog-box-not-in-center-in-chrome