jquery-archive / jquery-mobile

jQuery Mobile Framework
https://jquerymobile.com
Other
9.69k stars 2.4k forks source link

Button: Disable method doesn't work #6003

Closed demonslord closed 11 years ago

demonslord commented 11 years ago

Hi, I noticed that the event disabled doesn't work.

Here live demo: http://jsbin.com/axileq/1/

Best Regards.

jaspermdegroot commented 11 years ago

@demonslord

buttonMarkup is a function that is called by many widgets to create the markup for button styled elements (listview buttons, selectmenu, etc.). It is not a widget, so it doesn't have a disable or refresh method.

Form buttons (button and input type button/submit/reset elements) use the button widget. In this widget there is a call to buttonMarkup(). The button widget does have disable and refresh methods. So this works: http://jsbin.com/axileq/4/edit. Note that in this case there is no need to refresh.

Our button widget API documentation is wrong/confusing: http://api.jquerymobile.com/button/ It also contains information about styling links as buttons. anchor elements with data-role="button" don't use the button widget. They don't use any widget at all, we just use buttonMarkup() to style them, so this information doesn't belong there. I see there is already a ticket for this issue (https://github.com/jquery/api.jquerymobile.com/issues/85) and will comment there.

Closing this ticket because it's not a bug.

demonslord commented 11 years ago

Pretty clear. Thanks.

demonslord commented 11 years ago

One more question:

and in case of anchor?

http://jsbin.com/axileq/8/edit

demonslord commented 11 years ago

Answer to my question: adding "ui-disabled" class resolve this problem.

Thanks.

gonzaloazcuy commented 7 years ago

If you define like this:
$("#mybtn").button();

you must enable/disable like this:

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