BUG Adjust the tree construction and triggers to work with IE.

After Hamish's suggestion. Entwine onchange would not get executed in
IE8 at all, which would have the effect of the displyed dropdown
selection not being set.

Change to onadd also mandates the changes to onadd on other parts of the
tree component - otherwise the change event can trigger before the
tree elements are added to the DOM.
This commit is contained in:
Mateusz Uzdowski 2012-07-12 14:46:23 +12:00
parent 7c41ff22ab
commit c785f3c492

View File

@ -29,7 +29,7 @@
* @todo Expand title height to fit all elements * @todo Expand title height to fit all elements
*/ */
$('.TreeDropdownField').entwine({ $('.TreeDropdownField').entwine({
onmatch: function() { onadd: function() {
this.append( this.append(
'<span class="treedropdownfield-title"></span>' + '<span class="treedropdownfield-title"></span>' +
'<div class="treedropdownfield-toggle-panel-link"><a href="#" class="ui-icon ui-icon-triangle-1-s"></a></div>' + '<div class="treedropdownfield-toggle-panel-link"><a href="#" class="ui-icon ui-icon-triangle-1-s"></a></div>' +
@ -43,9 +43,6 @@
this.getPanel().hide(); this.getPanel().hide();
this._super(); this._super();
}, },
onunmatch: function() {
this._super();
},
getPanel: function() { getPanel: function() {
return this.find('.treedropdownfield-panel'); return this.find('.treedropdownfield-panel');
}, },
@ -260,7 +257,7 @@
}); });
$('.TreeDropdownField.searchable').entwine({ $('.TreeDropdownField.searchable').entwine({
onmatch: function() { onadd: function() {
this._super(); this._super();
var title = this.data('title'); var title = this.data('title');
@ -270,9 +267,6 @@
this.setTitle(title ? title : strings.searchFieldTitle); this.setTitle(title ? title : strings.searchFieldTitle);
}, },
onunmatch: function() {
this._super();
},
setTitle: function(title) { setTitle: function(title) {
if(!title && title !== '') title = strings.fieldTitle; if(!title && title !== '') title = strings.fieldTitle;
@ -372,8 +366,13 @@
}); });
$('.TreeDropdownField input[type=hidden]').entwine({ $('.TreeDropdownField input[type=hidden]').entwine({
onchange: function() { onadd: function() {
this.getField().updateTitle(); this.bind('change.TreeDropdownField', function() {
$(this).getField().updateTitle();
});
},
onremove: function() {
this.unbind('.TreeDropdownField');
} }
}); });
}); });