From eaf0fe4b2ff728c723eaad3d293cad2a8c180b7f Mon Sep 17 00:00:00 2001 From: Robert Curry Date: Wed, 12 Jun 2013 16:59:07 +1200 Subject: [PATCH] BUG Fix JS issues in treedropdownfield for link editor --- javascript/TreeDropdownField.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/javascript/TreeDropdownField.js b/javascript/TreeDropdownField.js index f9d713118..2385f4af3 100644 --- a/javascript/TreeDropdownField.js +++ b/javascript/TreeDropdownField.js @@ -114,7 +114,7 @@ var node = tree.find('*[data-id="' + val + '"]'), title = node.children('a').find("span.jstree_pageicon")?node.children('a').find("span.item").html():null; - if(!title) title=(node) ? tree.jstree('get_text', node[0]) : null; + if(!title) title=(node.length > 0) ? tree.jstree('get_text', node[0]) : null; if(title) self.setTitle(title); if(node) tree.jstree('select_node', node); @@ -122,8 +122,8 @@ }; // Load the tree if its not already present - if(jQuery.jstree._reference(tree) || !val) updateFn(); - else this.loadTree(null, updateFn); + if(!tree.is(':empty') || !val) updateFn(); + else this.loadTree({forceValue: val}, updateFn); }, setValue: function(val) { this.data('metadata', $.extend(this.data('metadata'), {id: val}));