I am facing a very challenging problem due to my little knowledge in jQuery mobile. I have researched many solutions and implemented them but does not seem to work
- I have a button called
click me
- When a user clicks on the button, the button becomes
disabled
and the textclickme
changes toplease wait...
- After 2 seconds the button become activated (no longer
disabled
) and the text changes fromplease wait...
back toclick me
. - I have gotten it to work to some extent. but i am finding it difficult to grab the right html code line in order to change
click me
toplease wait...
. - i am trying to use the example in this jsfiddle file http://jsfiddle.net/nogoodatcoding/ncSbz/1/ but integrate it within my
setTimeout
code.
Any help or guidance will be much appreciated. My code is below:
html content by jquery mobile
<div class="ui-btn ui-input-btn ui-corner-all ui-shadow">
clickme
<input class="submit button-primary btn large send" id="wp-submit" name="up_submit" tabindex="250" type="button" value="clickme">
</div>
jquery mobile code
$(document).ready(function () {
var clicked = false;
$('#wp-submit').bind('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.prev('div').find('div.ui-input-btn').text('Please wait...'); // sets the text
$btn.val('Please wait...'); // sets the text on the button itself
clicked = true;
setTimeout(function() {
$btn.button('enable');
$btn.prev('a').find('span.ui-btn-text').text('click me');
$btn.val('click me');
clicked = false;
}, 2000);
}
});
});