Friday, March 4, 2011

"Node cannot be inserted at the specified point in the hierarchy"

Hi, I am doing JavaScript Scaffold-like thing. And, code below is showing table. It works normal for all of them, and not for only one table I am getting - in the centring of processing on the third row - I get exception "Node cannot be inserted at the specified point in the hierarchy".

   function table_one_view(table) {
        $.getJSON('<%= Url.Action("TableOneView", "Scaffold") %>', { table: table },
                function(out) {
                    var tl = tpl('.table-one-view');
                    ctr().empty().append(tl);

                    $.each(out.columns, function(i, n) {
                        tl.find('thead > tr').append(
                            tpl('.table-one-view-header').html(n.name)
                        );
                    });

                    for (var y = 0; y < out.rows.length; y++) {
                        var tl_row = tpl('.table-one-view-row');

                        for (var x = 0; x < out.rows[y].length; x++) {
                            //error is here
                            tl_row.append(tpl('.table-one-view-cell').html(out.rows[y][x] ? out.rows[y][x] : "&nbsp;"));
                        }

                        tl.find('tbody').append(tl_row);
                    }
                }
          );
    }

    function tpl(query) {
      var t = $('.template ' + query).clone(true).removeClass('in');
      t.find('.in').remove();
      return t; 
    }
    function ctr() { return $('.container.scaffold'); }

Sooner, I could give you link, that you could test and see error in runtime.

From stackoverflow
  • I fixed this, when used

    out.rows[y][x].toString()
    

0 comments:

Post a Comment