2010-10-26 111 views
3

我只在IE7中遇到了标题栏的宽度问题。第一个使用宽度打开的对话框函数:'auto'标题栏不会在整个对话框中延伸。使用minWidth的第二个函数可以工作,但其行为更像宽度属性,不会随内容大小增长。有任何想法吗?jQuery对话框IE7问题

不工作:

 $(dialogId).dialog({ 
      autoOpen: 'false', 
      modal: true, 
      draggable: false, 
      resizable: false, 
      buttons: buttons, 
      title: title, 
      width: 'auto', 
      open: function(){ 
       /* IE HACK */ 
       $buttonPane = $(this).next(); 
       $buttonPane.find('button:first').addClass('accept').addClass('action'); 
       $('.ui-dialog-titlebar-close').hide(); 
       $('.ui-dialog').addClass('open_dialog'); 
       $(this).css('overflow','hidden');// IE hack 
       onOpen; 
      }, 
      close: function(){ 
       $('.ui-dialog').removeClass('open_dialog'); 
       afterClose; 
      } 
     }); 

工作(只固定宽度):

 $('#conf_dialog').dialog({ 
      dialogClass: dialogclass, 
      autoOpen: 'false', 
      modal: true, 
      draggable: false, 
      resizable: false, 
      buttons:buttons, 
      title:title, 
      minWidth: 255, 
      open: function(){ 
       /* IE HACK */ 
       $buttonPane = $(this).next(); 
       $buttonPane.find('button:first').addClass('accept').addClass('action'); 
       $('.ui-dialog-titlebar-close').hide(); 
      }, 
      close: afterClose 
     }); 
+0

你有没有解决这个问题的运气?我遇到了完全相同的问题... – Jules 2011-08-18 12:12:42

+0

宽度:auto不受支持:http://bugs.jqueryui.com/ticket/4437如果您查看API文档的宽度,具体只接受一种数字不是字符串/'汽车'。对于遇到此问题的其他人,如果尝试使用width:auto,则必须扩展/绑定到事件以自己调整标题大小。 – 2013-04-03 20:00:54

回答

2

理论上宽度:不支持自动,但似乎在IE8和FF的工作,但不能在IE7

我遇到了这个链接:

http://ovaraksin.blogspot.com/2011/05/jquery-ui-dialog-with-auto-width-and.html

和调整它这样:

 $("#myDialog").dialog({ autoOpen: false, 
      width: 'auto', 
      height: 'auto', 
      modal: true, 
      title: 'ABC...' 
     }).bind("dialogopen", function (event, ui) { 

      // fix for width:auto in IE 
      var contentWidth = $(this).width(); 
      $(this).parent().find('.ui-dialog-titlebar').each(function() { 
       $(this).width(contentWidth); 
      }); 

     }).bind("dialogclose", function (event, ui) { 
      //fix for width:auto in IE 
      $(this).parent().css("width", "auto"); 
     }); 
1

如果不定义宽度在所有会发生什么? 你试过宽度:100%?

+0

宽度100%只是将对话框扩展到整个窗口。没有定义宽度也没有帮助... – Jules 2011-08-18 12:14:17