Permalink
Browse files

Button: Sync disabled state upon refresh()

Fixes gh-7139
  • Loading branch information...
gabrielschulhof committed Feb 20, 2014
1 parent bfbdebb commit 5bb9ee8cf60fdc6a48da038de2df87dc9313bca7
Showing with 18 additions and 1 deletion.
  1. +7 −1 js/widgets/forms/button.js
  2. +10 −0 tests/unit/button/button_core.js
  3. +1 −0 tests/unit/button/index.html
@@ -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 });
+ }
}
});
@@ -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 );
@@ -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>

0 comments on commit 5bb9ee8

Please sign in to comment.