ARTLoe
ARTLoe

Reputation: 1799

This is for jQuery Mobile. Unable to disable my input button

I am trying to disable an input submit button.

the problem is,

  1. with my below code the button only seems to disable when the page is refreshed.
  2. i tried using $(this).atrr('refresh'); so once the button has been disabled it should refresh it so it visually appears to be disabled

any advise would be much appreciated

html

<input class="submit button-primary btn large send submit_wide" id="wp-submit" name="up_submit" tabindex="250" type="submit" value="test" />

jquery mobile code

<script type="text/javascript">
    $(document).ready(function () {
        var clicked = false;

        $('#wp-submit').click(function() {
            if(clicked === false) {
                $(this).attr('disabled','disabled');
                // $(this).atrr('refresh');
                clicked = true;
            } 
        });
    });
</script> 

Upvotes: 0

Views: 70

Answers (1)

Charles Follet
Charles Follet

Reputation: 827

Your solution works on JSFiddle :Fiddle. Maybe you can try the JQueryMobile function .button('disable') :

$(document).ready(function () {
        var clicked = false;

        $('#wp-submit').click(function() {
            if(clicked === false) {
                $(this).button('disable');  
               // $(this).attr('disabled','disabled');
                clicked = true;
            } 
        });
    });

Looks like refresh is a normal thing to do (From JQueryMobile website):

If you manipulate a form button via JavaScript, you must call the refresh method on it to update the visual styling.

$('[type="submit"]').button('refresh');

Upvotes: 1

Related Questions