Skip to content

Commit fdac605

Browse files
committed
checkboxradio inherits theme from parent page Fixes jquery-archive#3660
1 parent ee648e0 commit fdac605

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

js/jquery.mobile.forms.checkboxradio.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
4747
uncheckedicon: uncheckedicon
4848
});
4949

50-
// If there's no selected theme...
50+
// If there's no selected theme check the data attr
5151
if( !this.options.theme ) {
52-
this.options.theme = this.element.jqmData( "theme" );
52+
this.options.theme = $.mobile.getInheritedTheme( this.element, "c" );
5353
}
5454

5555
label.buttonMarkup({

tests/unit/checkboxradio/checkboxradio_core.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,13 @@
182182
}
183183
], 2000);
184184
});
185+
186+
187+
test( "theme should be inherited", function() {
188+
var $inherited = $( "#checkbox-inherit-theme" ),
189+
$explicit = $( "#checkbox-explicit-theme" );
190+
191+
ok( $inherited.siblings("label").hasClass( "ui-btn-up-a" ), "should inherit from page" );
192+
ok( $explicit.siblings("label").hasClass( "ui-btn-up-b" ), "should not inherit" );
193+
});
185194
})(jQuery);

tests/unit/checkboxradio/index.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ <h2 id="qunit-userAgent"></h2>
3636
<ol id="qunit-tests">
3737
</ol>
3838

39-
<div data-nstest-role="page">
39+
<div data-nstest-role="page" data-nstest-theme="a">
4040
<div data-nstest-role="content">
4141
<div data-nstest-role="fieldcontain">
4242
<fieldset data-nstest-role="controlgroup">
@@ -123,6 +123,20 @@ <h2 id="qunit-userAgent"></h2>
123123
<label for="checkbox-change-triggered-2">click triggered</label>
124124
</fieldset>
125125
</div>
126+
127+
<div data-role="fieldcontain">
128+
<fieldset data-role="controlgroup">
129+
<legend>Agree to the terms:</legend>
130+
<input type="checkbox" name="checkbox-inherit-theme" id="checkbox-inherit-theme"/>
131+
<label for="checkbox-inherit-theme">foo</label>
132+
</fieldset>
133+
134+
<fieldset data-role="controlgroup">
135+
<legend>Agree to the terms:</legend>
136+
<input type="checkbox" name="checkbox-explicit-theme" id="checkbox-explicit-theme" data-nstest-theme="b"/>
137+
<label for="checkbox-explicit-theme">foo</label>
138+
</fieldset>
139+
</div>
126140
</div>
127141

128142
<div id="enhancetest">

0 commit comments

Comments
 (0)