Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadData bug, not giving the node back #18

Closed
jivanrij opened this issue May 6, 2012 · 4 comments
Closed

loadData bug, not giving the node back #18

jivanrij opened this issue May 6, 2012 · 4 comments

Comments

@jivanrij
Copy link

jivanrij commented May 6, 2012

I think i found a bug, ik wanted to use loadData, it didn't work because the node i got back from getNodeById was null. After a bit of searching i saw that the node_id & node.id in the getNodeById function are beeing compared with ===, instead of ==.

JqueryWidget.prototype.getNodeById = function(node_id) {
  var result;
  result = null;
  this.tree.iterate(function(node) {
    if (node.id === node_id) {
      result = node;
      return false;
    } else {
      return true;
    }
  });
  return result;
};

jqTree is awesome btw, i love it :)

@mbraak
Copy link
Owner

mbraak commented May 6, 2012

This can be a problem if the node_id parameter is a string and the node ids are integers.

You can fix this by using parseInt:

var node = $('tree1').getNodeById(parseInt('30'));

Anyway, I do agree that using '==' would be better in this case. I can't change that at this moment because jqTree is written in CofeeScript, and CoffeeScript does not allow '==' (see http://coffeescript.org/#operators).

@jivanrij
Copy link
Author

jivanrij commented May 6, 2012

Oke, sounds logic, i'll do that.

@jivanrij jivanrij closed this as completed May 6, 2012
@mbraak
Copy link
Owner

mbraak commented Jun 2, 2012

Changed in the dev branch: the getNodeById comparison is now less strict. It uses the javascript '=='.

@jivanrij
Copy link
Author

thanks, i'm using 1.3.1 now, works fine :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants