ENHANCEMENT Triggering jQuery events in TreeSelectorField.js in preparation to switching the tree logic to jQuery. This prevents developers from using the soon-to-be-deprecated Observable prototype

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@92541 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-11-21 02:31:47 +00:00
parent 28109df438
commit d95f867945
2 changed files with 3 additions and 0 deletions

View File

@ -18,6 +18,7 @@ class TreeSelectorField extends FormField {
Requirements::javascript(THIRDPARTY_DIR . "/prototype_improvements.js"); Requirements::javascript(THIRDPARTY_DIR . "/prototype_improvements.js");
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang'); Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/jquery/jquery.js");
Requirements::javascript(SAPPHIRE_DIR . "/javascript/TreeSelectorField.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/TreeSelectorField.js");
$fieldName = $this->name; $fieldName = $this->name;

View File

@ -208,6 +208,7 @@ TreeDropdownField.prototype = {
if(this.inputTag.value != val) { if(this.inputTag.value != val) {
this.inputTag.value = val; this.inputTag.value = val;
jQuery(this).trigger('ss.TreeDropdownField.change', {val: val});
this.notify('Change', val); this.notify('Change', val);
// If the tree item is already downloaded, just update the label // If the tree item is already downloaded, just update the label
@ -240,6 +241,7 @@ TreeDropdownField.prototype = {
setValueFromTree: function(treeID, title) { setValueFromTree: function(treeID, title) {
this.humanItems.innerHTML = title; this.humanItems.innerHTML = title;
this.inputTag.value = treeID.replace('selector-' + this.getName() + '-',''); this.inputTag.value = treeID.replace('selector-' + this.getName() + '-','');
jQuery(this).trigger('ss.TreeDropdownField.change', {val: this.inputTag.value});
this.notify('Change', this.inputTag.value); this.notify('Change', this.inputTag.value);
this.hideTree(); this.hideTree();