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

Conflicts:
	js/jquery.mobile.forms.checkboxradio.js
This commit is contained in:
scottjehl 2011-07-10 17:17:51 -04:00
commit 033ce4ab96
3 changed files with 36 additions and 2 deletions

View file

@ -128,8 +128,11 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
},
//returns either a set of radios with the same name attribute, or a single checkbox
_getInputSet: function() {
return this.element.closest( "form,fieldset,:jqmData(role='page')" )
_getInputSet: function(){
if(this.inputtype == "checkbox") {
return this.element;
}
return this.element.closest( "form,fieldset,:jqmData(role='page')" )
.find( "input[name='"+ this.element.attr( "name" ) +"'][type='"+ this.inputtype +"']" );
},

View file

@ -27,6 +27,24 @@
ok( !button.hasClass( "ui-checkbox-on" ), "no active styles after click" );
});
test( "clicking a checkbox within a controlgroup does not affect checkboxes with the same name in the same controlgroup", function(){
var input1 = $("#checkbox-31");
var button1 = input1.parent().find(".ui-btn");
var input2 = $("#checkbox-32");
var button2 = input2.parent().find(".ui-btn");
ok(!input1.attr("checked"), "input1 not checked before click");
ok(!input2.attr("checked"), "input2 not checked before click");
button1.trigger("click");
ok(input1.attr("checked"), "input1 checked after click on input1");
ok(!input2.attr("checked"), "input2 not checked after click on input1");
button2.trigger("click");
ok(input1.attr("checked"), "input1 not changed after click on input2");
ok(input2.attr("checked"), "input2 checked after click on input2");
});
asyncTest( "change events fired on checkbox for both check and uncheck", function(){
var $checkbox = $( "#checkbox-2" ),
$checkboxLabel = $checkbox.parent().find( ".ui-btn" );

View file

@ -41,6 +41,19 @@
<label for="checkbox-2">I agree</label>
</fieldset>
</div>
<div data-nstest-role="fieldcontain" data-nstest-role="controlgroup">
<div>
<legend>Agree to the terms 3.1:</legend>
<input type="checkbox" name="checkbox-3" id="checkbox-31" class="custom"/>
<label for="checkbox-31">I agree 3.1</label>
</div>
<div>
<legend>Agree to the terms 3.2:</legend>
<input type="checkbox" name="checkbox-3" id="checkbox-32" class="custom"/>
<label for="checkbox-32">I agree 3.2</label>
</div>
</div>
</div>
<div data-role="fieldcontain" id="radio-active-btn-test">