Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit fcc5c34

Browse files
Checkboxradio: restore active state for buttons in horizontal controlgroups
1 parent 558eb5f commit fcc5c34

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

js/widgets/forms/checkboxradio.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
3636
uncheckedState = inputtype + "-off",
3737
icon = uncheckedState,
3838
iconpos = inheritAttr( input, "iconpos" ),
39-
activeBtn = icon ? "" : " " + $.mobile.activeBtnClass,
40-
checkedClass = "ui-" + checkedState + activeBtn,
39+
horizontal = input.parents( ":jqmData(type='horizontal')" ).length,
40+
activeBtn = $.mobile.activeBtnClass,
41+
checkedClass = "ui-" + checkedState,
4142
uncheckedClass = "ui-" + uncheckedState,
4243
checkedicon = icon ? checkedState : undefined,
4344
uncheckedicon = icon ? uncheckedState : undefined;
@@ -50,6 +51,8 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
5051
$.extend( this, {
5152
label: label,
5253
inputtype: inputtype,
54+
horizontal: horizontal,
55+
activeBtn: activeBtn,
5356
checkedClass: checkedClass,
5457
uncheckedClass: uncheckedClass,
5558
checkedicon: checkedicon,
@@ -182,11 +185,15 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
182185
refresh: function() {
183186
var input = this.element[0],
184187
label = this.label;
188+
189+
if ( this.horizontal ) {
190+
this.checkedClass = this.checkedClass + " " + this.activeBtn;
191+
}
185192

186193
if ( input.checked ) {
187194
label.addClass( this.checkedClass ).removeClass( this.uncheckedClass ).buttonMarkup( { icon: this.checkedicon } );
188195
} else {
189-
label.removeClass( this.checkedClass ).addClass( this.uncheckedClass ).buttonMarkup( { icon: this.uncheckedicon } );;
196+
label.removeClass( this.checkedClass ).addClass( this.uncheckedClass ).buttonMarkup( { icon: this.uncheckedicon } );
190197
}
191198

192199
if ( input.disabled ) {

0 commit comments

Comments
 (0)