2011-05-06 78 views
1

我想加載一個包含一些dojo代碼的頁面時遇到了問題。加載的頁面不顯示任何信息。Jquery和Dojo DataGrid問題

我所加載的網頁,index.html的樣子說:

<html> 
<head> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js" djConfig="parseOnLoad: true"> 
//to fill 
</script> 
    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/claro/claro.css"/> 
    </head> 
    <body> 
    <div id="mainFrame"> 
<script type="text/javascript" > 
$('#mainFrame').load('/Page.html'); 
</script> 
</div> 
    </body> 
    <html> 

我的第二頁包含的代碼來顯示一個DataGrid:當我運行這段代碼Pahe.html

<html> 
    <head> 
    <link rel='stylesheet' type='text/css' href='http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojox/grid/resources/claroGrid.css'/> 
     <script type="text/javascript" > 
     dojo.require("dojox.grid.DataGrid"); 
     dojo.require("dojo.data.ItemFileReadStore"); 
     function prepare() { 
      var data0 =[{FristName:'jean',LastName:'edu',Course:'english'}]; 
      var store0 = new dojo.data.ItemFileReadStore({ 
      data: { 
      items: data0 
      } 
      }); 
      var grid0 = new dojox.grid.DataGrid({ 
      store: store0, 
      structure: [ 
      {field: 'FirstName', name: 'FirstName', width:'auto'}, 
      {field: 'LastName', name: 'LastName', width:'auto'}, 
      {field: 'Course', name: 'Course', width:'auto'} 
      ], 
      rowsPerPage: 20, 
      clientSort : true, 
      rowSelector : '10px' 
      }, "grid0"); 
      grid0.startup(); 
     } 
     dojo.addOnLoad(prepare); 
    </script> 
    </head> 
    <body> 
    <div id="grid0"/> 
    </body> 
    </html> 

在瀏覽器中,我看到了。然而,我看到與谷歌瀏覽器的前景工具,瀏覽器加載的數據網格dojo ...

我認爲這是一個jquery的負載問題,因爲如果我添加代碼來加載腳本在頁面.html',我可以看到一些東西...我客人說jquery和dojo出了問題...

你能幫我解決嗎?

由於提前,

蝙蝠

回答

0

只是想大聲這裏也許,但你調用$(「#的mainFrame」)上方內嵌相應的「主機」格在文檔中。這會工作嗎?我會認爲js調用需要位於文檔中的「mainframe」div下方。

我會嘗試將該調用移出「head」,並將其放在「mainframe」div之後的某個位置。

+0

我改變了代碼(在我的主題上編輯)。但我仍然有這個問題。 – user376112 2011-05-06 13:36:14

0

我去看看針對JQuery的負載API文檔,但它帶來了一個空白頁:-)

我不知道正是它,特別是HEAD元素,但如果它是簡單地做就像innerHTML分配一樣,它不能用於Dojo的代碼加載器或CDN跨域加載。您可能希望在頁面加載時執行Dojo代碼。

0

2建議:

1-您可能需要進口道場電網 「基地」 網格CSS。

<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojox/grid/resources/Grid.css"> 

2 - 您可能還需要設置數據網格的高度(以像素爲單位百分比...不與數據網格工作)。