jQM change button text

by Erik Zanker

HTML

<div data-role="page" id="page1">  
    <div data-role="header">
         <h1>My page</h1> 
    </div>
    <div role="main" class="ui-content">        
        <input  id="wp-submit" name="up_submit" tabindex="250" type="button" value="click me" />
    </div>
    <div data-role="footer" data-position="fixed">
         <h1>Footer</h1> 
    </div>
</div>

JavaScript

$(document).on("pagecreate", "#page1", function () {

    var clicked = false;
    $('#wp-submit').on('click', function() {
        if(clicked == false) {
            // store reference to the button clicked
            // this allows us to access it within the 
            // setTimeout callback below.
            var $btn = $(this);

            $btn.button('disable');
            $btn.val('Please wait...').button('refresh');
            clicked = true;

            setTimeout(function() { 
                $btn.button('enable'); 
                $btn.val('click me').button('refresh');
                clicked = false;
            }, 2000); 
        }
    });
     
});