Skip to content
This repository
Browse code

Merge branch 'fix_issue_1851' of https://github.com/tigbro/jquery-mobile

into tigbro-fix_issue_1851

Conflicts:
	js/jquery.mobile.forms.checkboxradio.js
  • Loading branch information...
commit 033ce4ab9622ff42ed0655899116029481075db6 2 parents 47cb8cb + ec06fc1
authored July 10, 2011
7  js/jquery.mobile.forms.checkboxradio.js
@@ -128,8 +128,11 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
128 128
 	},
129 129
 
130 130
 	//returns either a set of radios with the same name attribute, or a single checkbox
131  
-	_getInputSet: function() {
132  
-		return this.element.closest( "form,fieldset,:jqmData(role='page')" )
  131
+	_getInputSet: function(){
  132
+        if(this.inputtype == "checkbox") {
  133
+            return this.element;
  134
+        }
  135
+        return this.element.closest( "form,fieldset,:jqmData(role='page')" )
133 136
 				.find( "input[name='"+ this.element.attr( "name" ) +"'][type='"+ this.inputtype +"']" );
134 137
 	},
135 138
 
18  tests/unit/checkboxradio/checkboxradio_core.js
@@ -27,6 +27,24 @@
27 27
 		ok( !button.hasClass( "ui-checkbox-on" ), "no active styles after click" );
28 28
 	});
29 29
 
  30
+    test( "clicking a checkbox within a controlgroup does not affect checkboxes with the same name in the same controlgroup", function(){
  31
+        var input1 = $("#checkbox-31");
  32
+        var button1 = input1.parent().find(".ui-btn");
  33
+        var input2 = $("#checkbox-32");
  34
+        var button2 = input2.parent().find(".ui-btn");
  35
+
  36
+        ok(!input1.attr("checked"), "input1 not checked before click");
  37
+        ok(!input2.attr("checked"), "input2 not checked before click");
  38
+
  39
+        button1.trigger("click");
  40
+        ok(input1.attr("checked"), "input1 checked after click on input1");
  41
+        ok(!input2.attr("checked"), "input2 not checked after click on input1");
  42
+
  43
+        button2.trigger("click");
  44
+        ok(input1.attr("checked"), "input1 not changed after click on input2");
  45
+        ok(input2.attr("checked"), "input2 checked after click on input2");
  46
+    });
  47
+
30 48
 	asyncTest( "change events fired on checkbox for both check and uncheck", function(){
31 49
 		var $checkbox = $( "#checkbox-2" ),
32 50
 			$checkboxLabel = $checkbox.parent().find( ".ui-btn" );
13  tests/unit/checkboxradio/index.html
@@ -41,6 +41,19 @@ <h2 id="qunit-userAgent"></h2>
41 41
 				<label for="checkbox-2">I agree</label>
42 42
 			</fieldset>
43 43
 		</div>
  44
+
  45
+        <div data-nstest-role="fieldcontain" data-nstest-role="controlgroup">
  46
+            <div>
  47
+                <legend>Agree to the terms 3.1:</legend>
  48
+                <input type="checkbox" name="checkbox-3" id="checkbox-31" class="custom"/>
  49
+                <label for="checkbox-31">I agree 3.1</label>
  50
+            </div>
  51
+            <div>
  52
+                <legend>Agree to the terms 3.2:</legend>
  53
+                <input type="checkbox" name="checkbox-3" id="checkbox-32" class="custom"/>
  54
+                <label for="checkbox-32">I agree 3.2</label>
  55
+            </div>
  56
+        </div>
44 57
 	</div>
45 58
 
46 59
 <div data-role="fieldcontain" id="radio-active-btn-test">

0 notes on commit 033ce4a

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