- $(document).on('pageinit', function()
- {
- var navph = GetPhoneNumber);
- $('#nvphone').changeButtonText(navph);
- });
- // found this funciotn online.....
- (function($) {
- /*
- * Changes the displayed text for a jquery mobile button.
- * Encapsulates the idiosyncracies of how jquery re-arranges the DOM
- * to display a button for either an <a> link or <input type="button">
- */
- $.fn.changeButtonText = function(newText) {
- return this.each(function() {
- $this = $(this);
- if( $this.is('a') ) {
- $('span.ui-btn-text',$this).text(newText);
- return;
- }
- if( $this.is('input') ) {
- $this.val(newText);
- // go up the tree
- var ctx = $this.closest('.ui-btn');
- $('span.ui-btn-text',ctx).text(newText);
- return;
- }
- });
- };
- })(jQuery);
When the page gets loaded, the button displays the expected phone number. There are other buttons on the page that load THE SAME page, but change the content. But, for each of those pages, the text of the button becomes empty. If I manually refresh the page, the button text gets set and displayed correctly.