My favorites | Sign in
Project Home Downloads
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 180: sortChildren() not working in Safari
1 person starred this issue and may be notified of changes. Back to list
Status:  Verified
Owner:  ----
Closed:  Feb 2011


 
Reported by oll...@gmail.com, Feb 3, 2011
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 4, 2011
Project Member #1 moo...@wwwendt.de
(No comment was entered for this change.)
Status: Accepted
Labels: Milestone-Release1.1.1
Feb 5, 2011
Project Member #2 moo...@wwwendt.de
This issue was closed by revision r462.
Status: Fixed
Feb 6, 2011
#3 oll...@gmail.com
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
Project Member #4 moo...@wwwendt.de
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
#5 oll...@gmail.com
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
Project Member #6 moo...@wwwendt.de
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
#7 oll...@gmail.com
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
Project Member #8 moo...@wwwendt.de
considered verified
Jul 17, 2012
Project Member #9 moo...@wwwendt.de
(No comment was entered for this change.)
Status: Verified

Powered by Google Project Hosting