backport stable branch
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Thu, 28 May 2009 19:07:41 +0200
changeset 1993 b3b51389566b
parent 1991 8a9d8f1ee100 (current diff)
parent 1992 b073057c2756 (diff)
child 1996 2490e18fd3c8
backport stable branch
--- a/web/data/cubicweb.preferences.js	Thu May 28 16:59:14 2009 +0200
+++ b/web/data/cubicweb.preferences.js	Thu May 28 19:07:41 2009 +0200
@@ -84,10 +84,8 @@
     jQuery(form).find('[type=text]').each(function () {
 	    unfreezeButtons = _checkValue(jQuery(this), unfreezeButtons);
 	});
-    jQuery(form).find('input[type=radio]').each(function () {
-	    if (jQuery(this).attr('checked')){
-		unfreezeButtons = _checkValue(jQuery(this), unfreezeButtons);
-	    }
+    jQuery(form).find('input[type=radio]:checked').each(function () {
+            unfreezeButtons = _checkValue(jQuery(this), unfreezeButtons);
      });
 
     if (unfreezeButtons){
@@ -103,7 +101,7 @@
 
 function _checkValue(input, unfreezeButtons){
      var currentValueInput = jQuery("input[name=current-" + input.attr('name') + "]");
-     if (currentValueInput.attr('value') != input.attr('value')){
+     if (currentValueInput.val() != input.val()){
 	 input.addClass('changed');
 	 unfreezeButtons = true;
      }else{
@@ -121,12 +119,15 @@
 	    var name = currentValueInput.attr('name').split('-')[1];
 	    jQuery(form).find("[name=" + name + "]").each(function (){
 		    var input = jQuery(this);
-		    if(input.attr('type')=='radio'){
-			if(input.attr('checked')){
-			    currentValueInput.attr('value', input.attr('value'));
+		    if(input.attr('type') == 'radio'){
+			// NOTE: there seems to be a bug with jQuery(input).attr('checked')
+			//       in our case, we can't rely on its value, we use
+			//       the DOM API instead.
+			if(input[0].checked){
+			    currentValueInput.val(input.val());
 			}
 		    }else{
-			currentValueInput.attr('value', input.attr('value'));
+			currentValueInput.val(input.val());
 		    }
 		});
     });