[facet] duh ? jQuery crashes on facets with only one element. Strange that this is the first time we hit this bug
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Fri, 29 May 2009 21:31:12 +0200
changeset 2013 5d30ad652e82
parent 2012 64c82e15fa98
child 2014 71a9ab77d9f8
[facet] duh ? jQuery crashes on facets with only one element. Strange that this is the first time we hit this bug
web/data/cubicweb.formfilter.js
--- a/web/data/cubicweb.formfilter.js	Fri May 29 21:30:19 2009 +0200
+++ b/web/data/cubicweb.formfilter.js	Fri May 29 21:31:12 2009 +0200
@@ -143,7 +143,11 @@
 			}).length;
 			index += shift;
 			var parent = this.parentNode;
-			jQuery(parent).find('.facetCheckBox:nth('+index+')').after(this);
+			var $insertAfter = jQuery(parent).find('.facetCheckBox:nth('+index+')');
+			if ( ! ($insertAfter.length == 1 && index == 0) ) {
+			    // only rearrange element if necessary
+			    $insertAfter.after(this);
+			}
 		    } else {
 			var lastSelected = facet.find('.facetValueSelected:last');
 			if (lastSelected.length) {