Sochettra / dynatree

Automatically exported from code.google.com/p/dynatree
0 stars 0 forks source link

sortChildren() not working in Safari #180

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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.

Original issue reported on code.google.com by oll...@gmail.com on 3 Feb 2011 at 11:30

GoogleCodeExporter commented 8 years ago

Original comment by moo...@wwwendt.de on 4 Feb 2011 at 9:16

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r462.

Original comment by moo...@wwwendt.de on 5 Feb 2011 at 7:32

GoogleCodeExporter commented 8 years ago
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?

Original comment by oll...@gmail.com on 6 Feb 2011 at 5:24

GoogleCodeExporter commented 8 years ago
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()

Original comment by moo...@wwwendt.de on 6 Feb 2011 at 7:41

GoogleCodeExporter commented 8 years ago
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.

Original comment by oll...@gmail.com on 7 Feb 2011 at 11:54

GoogleCodeExporter commented 8 years ago
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.

Original comment by moo...@wwwendt.de on 8 Feb 2011 at 7:42

GoogleCodeExporter commented 8 years ago
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.

Original comment by oll...@gmail.com on 8 Feb 2011 at 12:00

GoogleCodeExporter commented 8 years ago
considered verified

Original comment by moo...@wwwendt.de on 17 Jul 2012 at 4:16

GoogleCodeExporter commented 8 years ago

Original comment by moo...@wwwendt.de on 17 Jul 2012 at 4:19