Disabling a jQuery Mobile button using jQuery

This is my jQuery mobile button. This is probably easy. I can disable the html button, but I cannot get it with this mark.

<a href="" data-role="button" class="answer_but" id="a" data-theme="b" data-answer="1"> 

This is probably easy. Thanks

+6
source share
4 answers

Disable buttons in jQuery Mobile

Live Example: http://jsfiddle.net/XRjh2/16/

UPDATE:

Example link button:

Js

 var clicked = false; $('#myButton').click(function() { if(clicked === false) { $(this).addClass('ui-disabled'); clicked = true; alert('Button is now disabled'); } }); $('#enableButton').click(function() { $('#myButton').removeClass('ui-disabled'); clicked = false; }); 

HTML

 <div data-role="page" id="home"> <div data-role="content"> <a href="#" data-role="button" id="myButton">Click button</a> <a href="#" data-role="button" id="enableButton">Enable button</a> </div> </div> 

NOTE: - http://jquerymobile.com/demos/1.0rc2/docs/buttons/buttons-types.html

The links created as buttons have all the same visual parameters as the true ones based on the shape of the button below, but there are several important differences. Link-based buttons are not part of the button plugin and simply use the basic buttonMarkup plugin to create button styles so that the button methods of the form (enable, disable, update) are not supported. If you need to disable a button based on a link (or any element), you can use the disabled ui-disabled class yourself using JavaScript to achieve the same effect.

+5
source

You can simply set the class to "ui-disabled" for almost any element or button to disable it.

 <a data-role="filter-button" data-timeframe="month" class="ui-disabled">Date</a> 
+2
source

Hmmm - try this (if "a" is the id of your jqm button):

 // To disable $("#a").attr("disabled","disabled"); // and enable $("#a").attr("disabled",""); 
+1
source

So I looked at it and could not get it to work. Then a colleague suggested adding live to vclick, and now it works.

  //Disable Continue Button $('#icon-continue').live( 'vclick',function(event){ var clicked = false; if(clicked === false) { $(this).addClass('ui-disabled'); clicked = true; alert('Button is now disabled'); } }); 
0
source

Source: https://habr.com/ru/post/888134/


All Articles