2009-07-13 37 views
5

嘿,這又是我有一個關於jQuery的問題和gridlayout我做了一個PHP模板,開關,我插入的代碼是這樣節點不能在層次結構中的特定點插入3

<div id="wrapper"> 

<div id="grid"> 
<div class="box"><img src="img/an_005_BUR_thebeat.jpg" width="310px" height="438px" />3 index</div> 
<div class="box"><img src="img/an_014_GUE_homme_a.jpg" width="310px" height="404px" />4 Culture</div> 
<div class="box"><img src="img/an_044_BVL_springmotiv.jpg" width="310px" height="310px" />5 Pharma</div> 
<div class="box"><img src="img/an_039_AN_diskette.jpg" width="310px" height="465px" />6 Pharma IT</div> 
<div class="box"><img width="310px" height="100px" />7 Culture</div> 
<div class="box"><img width="310px" height="120px" />8 Cosmetics</div> 
<div class="box"><img width="310px" height="400px" />9 IT</div> 
<div class="box"><img width="310px" height="400px" />10 Culture</div> 
<div class="box"><img width="310px" height="400px" />11 IT</div> 
<div class="box"><img width="310px" height="400px" />12 Culture</div> 
</div> 

</div> 
    <script type="text/javascript"> 

    $(document).ready(function(){ 

     $('#grid').gridLayout('.box', {col_width: 340, min_cols: 2}); 
     // options - (values above are the defaults) 
     // col_width: the width of each grid block 
     // min_cols: the minimum number of cols on the page (reducing browser width below this will not decrease number of columns). Set to your largest block (3 = block spans 3 columns) 

     // gridLayout.placeAtEnd() - for placing a block at bottom right of grid 
     var final_block = $(''); 
     $('#grid').gridLayout.placeAtEnd(final_block); 

     // gridchange event fires when window resize forces a grid refresh 
     $('#grid').bind("gridchange", function(e){ 
      console.log('gridchange event fired'); 
      // reposition the final block 
      $('#grid').gridLayout.placeAtEnd(final_block); 
     }); 

     // this forces a redraw of grid 
     $('body').gridLayout.refresh(); 

     // returns heights of each column 
     console.log('gridLayout.info():', $('#grid').gridLayout.info()); 
    }); 

</script> 

jquery腳本和插件被加載到標題中。當我嘗試運行這個。螢火告訴我:

代碼「節點不能在層次結構中的指定插入點」:「3」

難道有人知道如何解決這一問題?

下面是一個例子,我裝起來:http://18735.webhosting7.1blu.de/neu/index.php?item=lifestyle

+0

在哪一行顯示這個錯誤? – peirix 2009-07-13 12:44:38

+0

完整的標記會有所幫助。錯誤意味着你(插件)試圖將一個節點插入一個無效的父節點,例如一個td到一個表中。 – redsquare 2009-07-13 12:45:00

回答

6

我敢肯定你的錯誤是與以下。什麼是$('')!

var final_block = $(''); 
$('#grid').gridLayout.placeAtEnd(final_block); 

它的工作原理,如果我說

var final_block = $('<div />'); 
$('#grid').gridLayout.placeAtEnd(final_block); 
3

顯示錯誤消息(螢火蟲)如果您在$()構造有不正確的HTML,以及當您嘗試添加一個節點自己,例如:

$div = $('<div />'); 
$div.append($div); 
相關問題