2010-09-10 68 views
0

我试图在我的应用程序的页面中使用dojo的对话框,但IE7中的页面出现了一些问题(或者在某些情况下,在IE 8中有一些问题,当页面以兼容模式查看时)。 以下是我正在尝试编写的页面的粗略框架结构。IE8中的dojo对话框问题

<head> 
    <style type="text/css"> 
     body, html { font-family:helvetica,arial,sans-serif; font-size:90%; } 
    </style> 
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js" 
    djConfig="parseOnLoad: true"> 
    </script> 
    <script type="text/javascript"> 
     dojo.require("dijit.Dialog"); 

     var secondDlg; 
     dojo.addOnLoad(function() { 
       var foo = new dijit.Dialog({id:'testDialog', title: "test dialog", content: "test content" }, dojo.byId('dialog1Container')); 
       foo.startup(); 


       var foo2 = new dijit.Dialog({id:'testDialog2', title: "test dialog 2", content: "test content 2" }, dojo.byId('dialog2Container')); 
       foo2.startup(); 
     }); 

     wrapper = function() { 
      dijit.byId('testDialog').show(); 
     } 
    </script> 
    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/claro/claro.css" 
    /> 
</head> 

<body class=" claro "> 
    <p> 
     When pressing this button the dialog will popup. Notice this time there 
     is no DOM node with content for the dialog: 
    </p> 
    <a onClick="wrapper();"> Show the test dialog</a> 
    <br /> 
    <a onClick="dijit.byId('testDialog2').show();"> Show the test dialog</a> 
    <div id="dialog1Container"></div> 
    <div id="dialog2Container"></div> 

    </body> 

在IE7中,页面时,它会尝试从第一链接显示对话框只是挂起。 下面是生病此页面的弊病的一些症状:

  • 它打破了,如果有在DOM超过1 Dijit.dialog。如果只有1个,那么它工作正常
  • 如果dom中有多个对话框实例,则只有最后一个对话框可以正常工作。所有先前的结果都会导致浏览器冻结。
  • 我使用的解决方案是在我的js中动态创建dijit.Dialog的一个实例,并将其插入到dom容器中并搭建一个自定义方法来隐藏它。当我隐藏它时,我也会在对话框中调用destroy,以便从dom中删除对话框。这让我在我的网页多个地方,可以在时间

还有一些额外的信息的任何点使用的对话框中,但只有1将显示与存在于DOM:

  • 我使用的HTML文档类型是DTD XHTML 1.0过渡// EN”“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
  • 它工作在FF,铬和IE 8细,只有在中断IE 7
  • 我使用道场1.5(不一个来自谷歌的网站,但来自我的服务器的副本,但我不能把它放在示例代码中)

任何人有任何关于在IE 7中有问题的dojo对话框的想法?

回答

0

原来,这不是dijit Dialogs本身的问题,有一个事件处理程序(根本不连接到dojo)导致错误,这就是为什么它不能在独立页面中重现。