First instead
$(document).ready(function () {...
Use jQM page events like pagecreate:
$(document).on("pagecreate", "#pageid", function () {...
In addition, changing the button text is as simple as updating the input value, and then calling the button (“update”) on the jQM button widget:
$btn.val('Please wait...').button('refresh');
Putting it all together:
$(document).on("pagecreate", "#page1", function () {
var clicked = false;
$('#wp-submit').on('click', function() {
if(clicked == false) {
var $btn = $(this);
$btn.button('disable').val('Please wait...').button('refresh');
clicked = true;
setTimeout(function() {
$btn.button('enable').val('click me').button('refresh');
clicked = false;
}, 2000);
}
});
});
Work DEMO
Thie also works in earlier jQM versions: DEMO 1.3
source
share