Skip to content
This repository
Browse code

MINOR Removing special case handling for chosen.js from UploadField, …

…using generic change listener (incl. some iframe scoping fixes)
  • Loading branch information...
commit 3f19f4cec0e00a085be86aa40aebd56f18507ffb 1 parent 8e7d221
Ingo Schommer authored May 11, 2012

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

  1. 27  javascript/UploadField.js
27  javascript/UploadField.js
@@ -287,27 +287,18 @@
287 287
 				var editform = this.closest('.ss-uploadfield-item').find('.ss-uploadfield-item-editform');
288 288
 				var disabled;
289 289
 				var iframe = editform.find('iframe');
290  
-				var inputs = iframe.contents().find('.ss-uploadfield-edit-iframe input');
291  
-				var ulSelects =iframe.contents().find('.ss-uploadfield-edit-iframe .chzn-drop ul.chzn-results');
292  
-				
293  
-				for(var i=0;i<inputs.length;i++){
294  
-					$(inputs[i]).change(function(){
  290
+
  291
+				// Mark the row as changed if any of its form fields are edited
  292
+				iframe.contents().ready(function() {
  293
+					// Need to use the iframe's own jQuery, as custom event triggers
  294
+					// (e.g. from TreeDropdownField) can't be captured by the parent jQuery object.
  295
+					var iframe_jQuery = iframe.get(0).contentWindow.jQuery;
  296
+					iframe_jQuery(iframe_jQuery.find(':input')).bind('change', function(e){
295 297
 						editform.removeClass('edited'); 
296 298
 						editform.addClass('edited'); 
297 299
 					});
298  
-
299  
-				}	 
300  
-				for(var i=0;i<ulSelects.length;i++){
301  
-					var current= $(ulSelects[i]).find('li.result-selected');
302  
-					$(ulSelects[i]).children('li').click(function(){
303  
-						if(this !== current[0]){
304  
-							editform.removeClass('edited'); 
305  
-							editform.addClass('edited'); 
306  
-						}
307  
-					});
308  
-				}	
309  
-
310  
-
  300
+				});
  301
+				
311 302
 				if (editform.hasClass('loading')) {
312 303
 					// TODO Display loading indication, and register an event to toggle edit form 
313 304
 				} else {

0 notes on commit 3f19f4c

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