Skip to content

Commit a270eb5

Browse files
committed
Flipswitch: update demos to match implementation and fix mismatched text Fixes jquery-archive#6343 - Flipswitch using select: 'selected' attribute selects wrong option
1 parent 836c0f2 commit a270eb5

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

demos/widgets/flipswitch/index.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,19 @@
5353
<form>
5454
<label for="flip-select">Flip toggle switch select:</label>
5555
<select id="flip-select" name="flip-select" data-role="flipswitch">
56-
<option>On</option>
5756
<option>Off</option>
57+
<option>On</option>
5858
</select>
5959
</form>
6060
</div><!-- /demo-html -->
6161
<h2>Basic select switch second option selected</h2>
6262

6363
<div data-demo-html="true">
6464
<form>
65-
<label for="flip-select">Flip toggle switch select:</label>
66-
<select id="flip-select" name="flip-select" data-role="flipswitch">
67-
<option>On</option>
68-
<option selected>Off</option>
65+
<label for="flip-select-second">Flip toggle switch select:</label>
66+
<select id="flip-select-second" name="flip-select" data-role="flipswitch">
67+
<option>Off</option>
68+
<option selected>On</option>
6969
</select>
7070
</form>
7171
</div><!-- /demo-html -->

js/widgets/forms/flipswitch.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ $.widget( "mobile.flipswitch", $.extend({
7979
on = $( "<span tabindex='1'></span>" ),
8080
off = $( "<span></span>" ),
8181
type = this.element.get( 0 ).tagName,
82-
onText = ( type === "INPUT" ) ? this.options.onText : this.element.find( "option" ).eq( 0 ).text(),
83-
offText = ( type === "INPUT" ) ? this.options.offText : this.element.find( "option" ).eq( 1 ).text();
82+
onText = ( type === "INPUT" ) ? this.options.onText : this.element.find( "option" ).eq( 1 ).text(),
83+
offText = ( type === "INPUT" ) ? this.options.offText : this.element.find( "option" ).eq( 0 ).text();
8484

8585
on.addClass( "ui-flipswitch-on ui-btn ui-shadow ui-btn-inherit" ).text( onText );
8686
off.addClass( "ui-flipswitch-off" ).text( offText );
8787

88-
flipswitch.addClass( "ui-flipswitch ui-shadow-inset ui-corner-all ui-bar-" + theme + " " + ( this.options.wrapperClass ? this.options.wrapperClass : "" ) + " " + ( ( this.element.is( ":checked" ) || !this.element.find("option").eq(1).is(":selected") ) ? "ui-flipswitch-active" : "" ) + ( this.element.is(":disabled") ? " ui-state-disabled": "") + ( this.options.mini ? " ui-mini": "" ) ).append( on, off );
88+
flipswitch.addClass( "ui-flipswitch ui-shadow-inset ui-corner-all ui-bar-" + theme + " " + ( this.options.wrapperClass ? this.options.wrapperClass : "" ) + " " + ( ( this.element.is( ":checked" ) || this.element.find("option").eq(1).is(":selected") ) ? "ui-flipswitch-active" : "" ) + ( this.element.is(":disabled") ? " ui-state-disabled": "") + ( this.options.mini ? " ui-mini": "" ) ).append( on, off );
8989

9090
this.element.addClass( "ui-flipswitch-input" );
9191
this.element.after( flipswitch ).appendTo( flipswitch );

0 commit comments

Comments
 (0)