Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Button: Sync disabled state upon refresh() #7141

Closed
wants to merge 2 commits into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
8 js/widgets/forms/button.js
@@ -126,13 +126,19 @@ $.widget( "mobile.button", {
},
refresh: function( create ) {
+ var originalElement,
+ isDisabled = this.element.prop( "disabled" );
+
if ( this.options.icon && this.options.iconpos === "notext" && this.element.attr( "title" ) ) {
this.element.attr( "title", this.element.val() );
}
if ( !create ) {
- var originalElement = this.element.detach();
+ originalElement = this.element.detach();
$( this.wrapper ).text( this.element.val() ).append( originalElement );
}
+ if ( this.options.disabled !== isDisabled ) {
+ this._setOptions({ disabled: isDisabled });
+ }
}
});
View
10 tests/unit/button/button_core.js
@@ -44,4 +44,14 @@
ok( $htmlstring.find("sup").length, "HTML contained within a button element should carry over to the enhanced version" );
});
+ test( "Button's disabled state synced via refresh()", function() {
+ var button = $( "#disabled-state" );
+
+ button.prop( "disabled", true ).button( "refresh" );
+
+ deepEqual( button.parent().hasClass( "ui-state-disabled" ), true,
+ "class ui-state-disabled has been added to the wrapper" );
+ deepEqual( button.button( "option", "disabled" ), true, "option disabled is now true" );
+ });
+
})( jQuery );
View
1  tests/unit/button/index.html
@@ -64,6 +64,7 @@
<button id="theme-check-explicit" value="foo" data-nstest-theme="a"></button>
<button id="contains-html">Supports <sup>phrasing content</sup></button>
<input type="button" id="val-contains-html" value="<fake markup>"/>
+ <input type="button" id="disabled-state" value="ABC"/>
</div>
</div>
</body>
Something went wrong with that request. Please try again.