Permalink
Browse files

Checkboxradio: restore active state for buttons in horizontal control…

…groups
  • Loading branch information...
jaspermdegroot committed Nov 9, 2012
1 parent 558eb5f commit fcc5c3434741bcd310a2b61d7855b37505a3a11a
Showing with 10 additions and 3 deletions.
  1. +10 −3 js/widgets/forms/checkboxradio.js
@@ -36,8 +36,9 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
uncheckedState = inputtype + "-off",
icon = uncheckedState,
iconpos = inheritAttr( input, "iconpos" ),
activeBtn = icon ? "" : " " + $.mobile.activeBtnClass,
checkedClass = "ui-" + checkedState + activeBtn,
horizontal = input.parents( ":jqmData(type='horizontal')" ).length,
activeBtn = $.mobile.activeBtnClass,
checkedClass = "ui-" + checkedState,
uncheckedClass = "ui-" + uncheckedState,
checkedicon = icon ? checkedState : undefined,
uncheckedicon = icon ? uncheckedState : undefined;
@@ -50,6 +51,8 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
$.extend( this, {
label: label,
inputtype: inputtype,
horizontal: horizontal,
activeBtn: activeBtn,
checkedClass: checkedClass,
uncheckedClass: uncheckedClass,
checkedicon: checkedicon,
@@ -182,11 +185,15 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
refresh: function() {
var input = this.element[0],
label = this.label;
if ( this.horizontal ) {
this.checkedClass = this.checkedClass + " " + this.activeBtn;
}
if ( input.checked ) {
label.addClass( this.checkedClass ).removeClass( this.uncheckedClass ).buttonMarkup( { icon: this.checkedicon } );
} else {
label.removeClass( this.checkedClass ).addClass( this.uncheckedClass ).buttonMarkup( { icon: this.uncheckedicon } );;
label.removeClass( this.checkedClass ).addClass( this.uncheckedClass ).buttonMarkup( { icon: this.uncheckedicon } );
}
if ( input.disabled ) {

0 comments on commit fcc5c34

Please sign in to comment.