Permalink
Browse files

BUGFIX Changed sitetree default selection in LeftAndMain.Tree.js to f…

…ire on window.load instead of document.ready() through entwine. We need to ensure behaviour.js bindings are available before

BUGFIX Automatically selecting root node in CMS trees (necessary because now we actually have forms on the root node, and its a valid click target)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@99605 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 67205b0 commit ae844c5386bf89612fabb75638e4b7340458ebc3 @chillu chillu committed Feb 22, 2010
Showing with 9 additions and 15 deletions.
  1. +9 −15 javascript/LeftAndMain.Tree.js
@@ -17,18 +17,14 @@ var _HANDLER_FORMS = {
};
(function($) {
- /**
- * @class Tree panel.
- * @name ss.sitetree
- */
- $('#sitetree').concrete('ss', function($){
- return/** @lends ss.sitetree */{
- onmatch: function() {
- // make sure current ID of loaded form is actually selected in tree
- var id = $('#Form_EditForm :input[name=ID]').val();
- this[0].setCurrentByIdx(id);
- }
- };
+ $(window).bind('load', function(e) {
+ // behaviour.js load handlers need to be fired before this event, so we artificially delay it
+ setTimeout(function() {
+ // make sure current ID of loaded form is actually selected in tree
+ var tree = $('#sitetree')[0], id = $('#Form_EditForm :input[name=ID]').val();
+ if(!id) id = 0;
+ tree.setCurrentByIdx(id);
+ }, 200);
});
}(jQuery));
@@ -233,9 +229,7 @@ TreeNodeAPI.prototype = {
self.removeNodeClass('loading');
var pageID = jQuery(this).find(':input[name=ID]').val();
- if(pageID) {
- jQuery('#sitetree')[0].setCurrentByIdx(pageID);
- }
+ jQuery('#sitetree')[0].setCurrentByIdx(pageID);
}
);

0 comments on commit ae844c5

Please sign in to comment.