0

I'm using the jqtree plugin and I can't seem to get the tree to load in ie 8. I get an error in ie8 saying children is null or not an object. But I don't receive that error in any other browser.

The error occurs on the 8th line of the code below saying - Unable to get property 'children' of undefined or null reference.

Node.prototype.loadFromData = function(data) {
  var node, o, _i, _len;
  this.removeChildren();
  for (_i = 0, _len = data.length; _i < _len; _i++) {
    o = data[_i];
    node = new this.tree.node_class(o);
    this.addChild(node);
    if (typeof o === 'object' && o.children) {
      node.loadFromData(o.children);
    }
  }
  return null;
};

Here is my html

<!DOCTYPE html>
<html>
    <head>
    <meta charset="UTF-8"/>
    <title>EMC Automation Test Suite</title>
    <link rel="stylesheet" href="jqtree.css">
    <link rel="stylesheet" href="/fontawesome/css/font-awesome.min.css">
    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
    </head>

<body>
    <h1>EMC Automation Test Suite</h1>
    <div id="tree1" data-url="/treejsonobject/" class></div>
    <script src="scripts/jquery-1.11.1.js"></script>
    <script src="scripts/tree.jquery.js"></script>
    <script src="scripts/bootstrap.min.js"></script>
    <script src="scripts/jquery.cookie.js"></script>
    <script src="scripts/jquery.mockjax.js"></script>
    <script src="index.json"></script>
    <script src="scripts/save_state.js"></script>
</body>

and here is my java script

$.mockjax({
    url: '*',
    response: function(options) {
        this.responseText = TreeJsonObject.treejsonobject;
   },
   responseTime: 0
});

$(function() {
    $('#tree1').tree({
        saveState: true,
        saveState: 'my-tree',
        closedIcon: $('<i class="fa fa-plus-square"></i>'),
        openedIcon: $('<i class="fa fa-minus-square"></i>')
    });
});

I have tried adding this to my script

$(function() {
    $(#tree1).children().remove()
});

But this code just disables the tree from loading.

4

0 回答 0