Skip to content
This repository
Browse code

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...
commit c785f3c4923991b065dbda6768c68c8ea6872714 1 parent 7c41ff2
Mateusz U authored July 12, 2012

Showing 1 changed file with 9 additions and 10 deletions. Show diff stats Hide diff stats

  1. 19  javascript/TreeDropdownField.js
19  javascript/TreeDropdownField.js
@@ -29,7 +29,7 @@
29 29
 		 * @todo Expand title height to fit all elements
30 30
 		 */
31 31
 		$('.TreeDropdownField').entwine({
32  
-			onmatch: function() {
  32
+			onadd: function() {
33 33
 				this.append(
34 34
 					'<span class="treedropdownfield-title"></span>' +
35 35
 					'<div class="treedropdownfield-toggle-panel-link"><a href="#" class="ui-icon ui-icon-triangle-1-s"></a></div>' +
@@ -43,9 +43,6 @@
43 43
 				this.getPanel().hide();
44 44
 				this._super();
45 45
 			},
46  
-			onunmatch: function() {
47  
-				this._super();
48  
-			},
49 46
 			getPanel: function() {
50 47
 				return this.find('.treedropdownfield-panel');
51 48
 			},
@@ -260,7 +257,7 @@
260 257
 		});
261 258
 		
262 259
 		$('.TreeDropdownField.searchable').entwine({
263  
-			onmatch: function() {
  260
+			onadd: function() {
264 261
 				this._super();
265 262
 				
266 263
 				var title = this.data('title');
@@ -270,9 +267,6 @@
270 267
 				
271 268
 				this.setTitle(title ? title : strings.searchFieldTitle);
272 269
 			},
273  
-			onunmatch: function() {
274  
-				this._super();
275  
-			},
276 270
 			setTitle: function(title) {
277 271
 				if(!title && title !== '') title = strings.fieldTitle;
278 272
 				
@@ -372,8 +366,13 @@
372 366
 		});
373 367
 
374 368
 		$('.TreeDropdownField input[type=hidden]').entwine({
375  
-			onchange: function() {
376  
-				this.getField().updateTitle();
  369
+			onadd: function() {
  370
+				this.bind('change.TreeDropdownField', function() {
  371
+					$(this).getField().updateTitle();
  372
+				});
  373
+			},
  374
+			onremove: function() {
  375
+				this.unbind('.TreeDropdownField');
377 376
 			}
378 377
 		});
379 378
 	});

0 notes on commit c785f3c

Please sign in to comment.
Something went wrong with that request. Please try again.