After applying the http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css and http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js
the text of the
Final applying $('#button').prev().text('your new text');
work.
Just don't understanding why use .prev()
before changing the text.
Can you try this,
$(".ui-btn-text").text('Processing ...');
Code:
$(document).ready(function () {
$('#submit_btn').click(function (e) {
e.preventDefault();
$(".ui-btn-text").text('Processing ...');
$.ajax({
cache: false,
type: "POST",
dataType: "json",
data: $('#form1').serialize(),
url: "echo/json",
complete: function (HttpRequest, textStatus) {
$(".ui-btn-text").text('Create');
}
});
return false;
});
});
Demo : http://jsfiddle.net/Rz2sJ/4/
You're working with .button() widget of jQuery Mobile. <button>
is converted into a div to give it a new look by jQuery Mobile.
When doing any changes to <button>
or <a>
, you need to refresh that element to re-apply styles.
All you need to do is:
$(".selector").val('Processing ...').button("refresh");
Demo
By the time the AJAX callback runs, this
as a keyword has lost its context. You need to assign it to a variable to retain the reference. Something like this:
$(document).ready(function () {
$('#submit_btn').click(function (e) {
e.preventDefault();
var button = $(this);
button.val('Processing ...');
$.ajax({
cache: false,
type: "POST",
dataType: "json",
data: $('#form1').serialize(),
url: "echo/json",
complete: function (HttpRequest, textStatus) {
button.val('Create');
}
});
return false;
});
});