MINOR Changed TreeDropdownField markup from <div href="..."> to <div data-url-tree="..."> in order to support other URLs (e.g. reordering) - important for the main CMS tree

This commit is contained in:
Ingo Schommer 2011-03-10 16:12:46 +13:00
parent bde24b3415
commit 0b40bda1cc
4 changed files with 9 additions and 9 deletions

View File

@ -135,7 +135,7 @@ class TreeDropdownField extends FormField {
array (
'id' => "TreeDropdownField_{$this->id()}",
'class' => 'TreeDropdownField single' . ($this->extraClass() ? " {$this->extraClass()}" : '') . ($this->showSearch ? " searchable" : ''),
'href' => $this->form ? $this->Link('tree') : "",
'data-url-tree' => $this->form ? $this->Link('tree') : "",
'data-title' => $title,
),
$this->createTag (

View File

@ -113,7 +113,7 @@ class TreeMultiselectField extends TreeDropdownField {
array (
'id' => "TreeDropdownField_{$this->id()}",
'class' => 'TreeDropdownField multiple' . ($this->extraClass() ? " {$this->extraClass()}" : '') . ($this->showSearch ? " searchable" : ''),
'href' => $this->form ? $this->Link('tree') : "",
'data-url-tree' => $this->form ? $this->Link('tree') : "",
'data-title' => $title,
),
$this->createTag (

View File

@ -61,7 +61,7 @@
var self = this, panel = this.getPanel(), treeHolder = $(panel).find('.tree-holder');
var params = (params) ? this.getRequestParams().concat(params) : this.getRequestParams();
panel.addClass('loading');
treeHolder.load(this.attr('href'), params, function(html, status, xhr) {
treeHolder.load(this.data('url-tree'), params, function(html, status, xhr) {
var firstLoad = true;
if(status == 'success') {
$(this)
@ -101,7 +101,7 @@
// TODO Hack to avoid ajax load on init, see http://code.google.com/p/jstree/issues/detail?id=911
'data': this.getPanel().find('.tree-holder').html(),
'ajax': {
'url': this.attr('href'),
'url': this.data('url-tree'),
'data': function(node) {
var id = $(node).data("id") ? $(node).data("id") : 0, params = self.getRequestParams();
params = params.concat([{name: 'ID', value: id}, {name: 'ajax', value: 1}]);
@ -197,7 +197,7 @@
var self = this, panel = this.getPanel(), treeHolder = $(panel).find('.tree-holder');
var params = (params) ? this.getRequestParams().concat(params) : this.getRequestParams();
panel.addClass('loading');
treeHolder.load(this.attr('href'), params, function(html, status, xhr) {
treeHolder.load(this.data('url-tree'), params, function(html, status, xhr) {
var firstLoad = true;
if(status == 'success') {
$(this)

View File

@ -45,7 +45,7 @@
beforeEach(function() {
// load fixture
$('body').append(
'<div id="testfield" class="TreeDropdownField single" href="/myurl" data-title="Selected">' +
'<div id="testfield" class="TreeDropdownField single" data-url-tree="/myurl" data-title="Selected">' +
'<input type="hidden" name="testfield" value="1" />' +
'</div>'
);
@ -110,7 +110,7 @@
beforeEach(function() {
// load fixture
$('body').append(
'<div id="testfield" class="TreeDropdownField searchable" href="/myurl" data-title="Selected">' +
'<div id="testfield" class="TreeDropdownField searchable" data-url-tree="/myurl" data-title="Selected">' +
'<input type="hidden" name="testfield" value="1" />' +
'</div>'
);
@ -142,7 +142,7 @@
beforeEach(function() {
// load fixture (check one child node, one root node)
$('body').append(
'<div id="testfield" class="TreeDropdownField multiple" href="/myurl" data-title="Root Node 2,Root Node 3">' +
'<div id="testfield" class="TreeDropdownField multiple" data-url-tree="/myurl" data-title="Root Node 2,Root Node 3">' +
'<input type="hidden" name="testfield" value="4,5" />' +
'</div>'
);
@ -216,7 +216,7 @@
// load fixture
$('body').append(
'<form id="myform" url="/myform">' +
'<div id="testfield" class="TreeDropdownField" href="/myurl" data-title="Selected">' +
'<div id="testfield" class="TreeDropdownField" data-url-tree="/myurl" data-title="Selected">' +
'<input type="hidden" name="testfield" value="1" />' +
'</div>' +
'<input type="hidden" name="MyFormValue" value="foo" />' +