BUGFIX Changed sitetree default selection in LeftAndMain.Tree.js to fire 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
This commit is contained in:
Ingo Schommer 2010-02-22 19:49:51 +00:00
parent 67205b01e2
commit ae844c5386

View File

@ -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);
}
);