| Issue 180: | sortChildren() not working in Safari | |
| 1 person starred this issue and may be notified of changes. | Back to list |
The following code works fine in Chrome but not in Safari...
var node = $("#tree").dynatree("getTree").getNodeByKey("tree-1-brick");
alert(node);
node.sortChildren();
I alert the node just to make sure I am getting something which I most definitely am.
The result is to see nothing change in the tree in Safari.
Feb 6, 2011
I am now getting a change in the tree in Safari. But the sorted children are by no means in alphabetical order. Question ... if I keep pressing the button that calls sortChildren, should I expect the results to be different (e.g. reversed) or should it always sort ascending alphabeticaly?
Feb 6, 2011
The default compare functions sorts by ascii, i.e. checks
if(string1 > string2)...
so small caps are sorted after upper case.
If you want to reverse or change the order, you can pass a custom compare function to sortChildren()
Feb 7, 2011
Now in Chrome, I get no sorting results. I just see nothing happen in the tree. In Safari, although the tree is changing, the results are not alphabetical. Additionally, if I keep calling the sortChildren function on the tree, the results just go back and forth from the original, to the incorrectly sorted version. I am using titles like "b b" and "3) awesome" and "YOUTUBE" and "ALRIGHT" and I am not getting desired results.
Feb 7, 2011
I tested this on safari and chrome
// Custom compare function (optional) that sorts case insensitive
var cmp = function(a, b) {
a = a.data.title.toLowerCase();
b = b.data.title.toLowerCase();
return a > b ? 1 : a < b ? -1 : 0;
};
node.sortChildren(cmp, false);
maybe you can post a link to your sample.
Feb 8, 2011
I recopied the latest version and it is all working great, THANKS! Before I tried to take just the change you made and insert it into the minified version and I messed up with the spacing. Most definitely fixed.
Jul 17, 2012
considered verified
Jul 17, 2012
(No comment was entered for this change.)
Status:
Verified
|
Labels: Milestone-Release1.1.1