ablerman
ablerman

Reputation: 1543

How do I disable a jqueryui button

When I click on a jquery ui button, it still triggers the click event callback. How do I block that event? Do I have to manually keep track of the state or does jquery ui take care of that for me?

Upvotes: 30

Views: 33960

Answers (5)

MadMax
MadMax

Reputation: 615

It's actually:

$("#btn").button({"disabled":true});

Upvotes: 0

GAzcuy
GAzcuy

Reputation: 371

If you define like this:

$("#mybtn").button();

you must enable/disable like this:

$("#mybtn").button("enable");
// OR
$("#mybtn").button("disable");

Upvotes: 3

dixonpfu
dixonpfu

Reputation: 358

It works for me:

$("#button_id").attr("disabled", true).addClass("ui-state-disabled");

Upvotes: 24

Jarry
Jarry

Reputation: 1931

according the documentation:

// setter
$( "#button_id" ).button( "option", "disabled", true );

Upvotes: 18

jcubic
jcubic

Reputation: 66480

Try this.

$('#button_id').button("disable");
$('#button_id').button("enable");

Upvotes: 41

Related Questions