Permalink
Browse files

Button: Read disabled attribute from original element if disabled opt…

…ion is null. Fixes #5252 -Button: read disabled option from input elements.
  • Loading branch information...
1 parent 9060bf3 commit 2838c11ea8fa1bd8dfffe27a6e28dee6d3e0d423 @scottgonzalez scottgonzalez committed Aug 18, 2010
Showing with 30 additions and 1 deletion.
  1. +1 −1 tests/unit/button/button_defaults.js
  2. +24 −0 tests/unit/button/button_options.js
  3. +5 −0 ui/jquery.ui.button.js
@@ -3,7 +3,7 @@
*/
var button_defaults = {
- disabled: false,
+ disabled: null,
text: true,
label: null,
icons: {
@@ -5,6 +5,30 @@
module("button: options");
+test("disabled, explicity value", function() {
+ $("#radio01").button({ disabled: false });
+ same(false, $("#radio01").button("option", "disabled"),
+ "disabled option set to false");
+ same(false, $("#radio01").attr("disabled"), "element is disabled");
+
+ $("#radio02").button({ disabled: true });
+ same(true, $("#radio02").button("option", "disabled"),
+ "disabled option set to true");
+ same(true, $("#radio02").attr("disabled"), "element is not disabled");
+});
+
+test("disabled, null", function() {
+ $("#radio01").button({ disabled: null });
+ same(false, $("#radio01").button("option", "disabled"),
+ "disabled option set to false");
+ same(false, $("#radio01").attr("disabled"), "element is disabled");
+
+ $("#radio02").attr("disabled", "disabled").button({ disabled: null });
+ same(true, $("#radio02").button("option", "disabled"),
+ "disabled option set to true");
+ same(true, $("#radio02").attr("disabled"), "element is not disabled");
+});
+
test("text false without icon", function() {
$("#button").button({
text: false
View
@@ -44,6 +44,7 @@ var lastActive,
$.widget( "ui.button", {
options: {
+ disabled: null,
text: true,
label: null,
icons: {
@@ -56,6 +57,10 @@ $.widget( "ui.button", {
.unbind( "reset.button" )
.bind( "reset.button", formResetHandler );
+ if ( typeof this.options.disabled !== "boolean" ) {
+ this.options.disabled = this.element.attr( "disabled" );
+ }
+
this._determineButtonType();
this.hasTitle = !!this.buttonElement.attr( "title" );

0 comments on commit 2838c11

Please sign in to comment.