Sanya
Sanya

Reputation: 1280

jquery mobile update anchor text

When I change the anchor text - I lose all of my css. I cannot figure out how to keep the css. I even tried injecting the CSS back but still nothing. I tried ('refresh') but still nothing. Maybe I used it wrong.

(using jQuery Mobile 1.3.1 & jQuery 1.9.1)

**SEE THIS IMG --> http://www.appmalt.info/img/test.png

HTML

<div data-role='content' data-theme='b'>
    <a href='#leftPanel' data-role='button' data-theme='b' data-icon='list' data-iconpos='left' id='bTitle'>Acceleration</a>
    ........
    ........
</div>

jQuery

//The trigger initiates and calls a function. The function contains this
$('#bTitle').text('Area')
            .attr('data-role','button')
            .attr('data-icon','list')
            .attr('data-iconpos','left')
            .attr('data-theme','b')
            .css('text-decoration','none')
            .trigger('refresh');

The text changes just fine but all CSS is gone.

Upvotes: 1

Views: 992

Answers (1)

Eric Hotinger
Eric Hotinger

Reputation: 9316

Try

$("#bTitle .ui-btn-text").text('new_text')

since jQuery Mobile creates spans on its own.

Upvotes: 2

Related Questions