【问题标题】:Node cannot be inserted at the specified point in the hierarchy" code: "3无法在层次结构中的指定点插入节点”代码:“3
【发布时间】:2010-11-10 06:59:44
【问题描述】:

嘿,我又问了一个关于 jquery 的问题,gridlayout 我用 switch 做了一个 php 模板,我插入的代码是这个

<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 脚本和插件加载在标头中。当我尝试运行它时。 Firebug 告诉我:

“节点不能插入到层次结构中的指定点”代码:“3”

有人知道如何解决这个问题吗?

这是我加载的示例:http://18735.webhosting7.1blu.de/neu/index.php?item=lifestyle

【问题讨论】:

  • 这个错误出现在哪一行?
  • 完整的标记会有所帮助。该错误意味着您(插件)正在尝试将节点插入无效的父节点,例如将 td 插入表中。
  • 或在 jsbin.com 上模拟一个带有问题的演示
  • 我将整个内容上传到我的网络空间18735.webhosting7.1blu.de/neu/index.php?item=lifestyle
  • 错误发生在fragment.appendChild(ret[i]); jquery-1.3.2.js(第 957 行)

标签: jquery grid-layout


【解决方案1】:

我很确定您的错误与以下内容有关。 $('') 是什么!

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

如果我说它会起作用

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

【讨论】:

  • 不,这不是错误。在这个变量中,您可以放置​​一个 div,您希望 tp 最后出现。我只是把它留空,因为我不需要它..
  • 你是对的,错误消失了。但是仍然没有安排网格。它只是将 div 放在另一个之下。
  • 很酷,问题得到了回答:) 我会为您的下一个问题提出另一个问题。然后它将帮助其他有同样问题的人,而不是在这个问题下的答案(通过谷歌等很难找到)
【解决方案2】:

如果 $() 构造函数中的 html 不正确,以及尝试将节点附加到自身,则会显示错误消息(在 firebug 中),例如:

$div = $('<div />');
$div.append($div);

【讨论】:

    猜你喜欢
    • 2010-09-25
    • 1970-01-01
    • 2012-05-31
    • 2012-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多