Permalink
Browse files

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.
  • Loading branch information...
1 parent 7c41ff2 commit c785f3c4923991b065dbda6768c68c8ea6872714 @mateusz mateusz committed Jul 12, 2012
Showing with 9 additions and 10 deletions.
  1. +9 −10 javascript/TreeDropdownField.js
@@ -29,7 +29,7 @@
* @todo Expand title height to fit all elements
*/
$('.TreeDropdownField').entwine({
- onmatch: function() {
+ onadd: function() {
this.append(
'<span class="treedropdownfield-title"></span>' +
'<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._super();
},
- onunmatch: function() {
- this._super();
- },
getPanel: function() {
return this.find('.treedropdownfield-panel');
},
@@ -260,7 +257,7 @@
});
$('.TreeDropdownField.searchable').entwine({
- onmatch: function() {
+ onadd: function() {
this._super();
var title = this.data('title');
@@ -270,9 +267,6 @@
this.setTitle(title ? title : strings.searchFieldTitle);
},
- onunmatch: function() {
- this._super();
- },
setTitle: function(title) {
if(!title && title !== '') title = strings.fieldTitle;
@@ -372,8 +366,13 @@
});
$('.TreeDropdownField input[type=hidden]').entwine({
- onchange: function() {
- this.getField().updateTitle();
+ onadd: function() {
+ this.bind('change.TreeDropdownField', function() {
+ $(this).getField().updateTitle();
+ });
+ },
+ onremove: function() {
+ this.unbind('.TreeDropdownField');
}
});
});

0 comments on commit c785f3c

Please sign in to comment.