BUGFIX: tree selector base URL calculation wrong when field is nested

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@99739 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Mark Stephens 2010-02-23 22:26:11 +00:00 committed by Sam Minnee
parent b7ff50ac46
commit be7d3364ac

View File

@ -60,7 +60,14 @@ TreeDropdownField.prototype = {
// Build a URL from the field's base URL and the given sub URL
buildURL: function(subURL) {
var baseURL = jQuery(this).attr('href');
if (!baseURL) baseURL = this.ownerForm().action + '/field/' + this.getName() + '/';
if (!baseURL) {
// Occurs if treedropdown has no form e.g. treefields in widget areas.
baseURL = this.ownerForm().action + '/field/' + this.getName() + '/';
var baseTags = document.getElementsByTagName('base');
var base = (baseTags) ? baseTags[0].href : '';
if (base == baseURL.substring(0, base.length))
baseURL = baseURL.substring(base.length);
}
var subHasQuerystring = subURL.match(/\?/);
if(baseURL.match(/^(.*)\?(.*)$/)) {