2
I am having trouble updating an element, through jQuery. I will summarize the codes:
HTML
<div data-role="header" data-position="fixed" data-tap-toggle="false">
<a href="#nav-panel" data-icon="bars" data-iconpos="notext">Menu</a>
<h1>Ranking</h1>
<a id="btnPlayerName" href="#" class="ui-btn-right">Player</a>
</div>
<div data-role="content">
<ul id="rankingList" data-role="listview"></ul>
</div>
JS
$(document).on('pageshow', '#pagRanking', function() {
headerData();
})
function headerData() {
if(sessionStorage.getItem('mbPlayerID') == null) {
window.location.href="index.php";
}
$("#btnPlayerName").empty();
lblPN = '<span class="ui-btn-inner">';
lblPN += '<span class="ui-btn-class">';
lblPN += playerName;
lblPN += '</span>';
lblPN += '</span>';
$("#btnPlayerName").append(lblPN);
}
Everything is OK with Septssion, but the append
doesn’t work.
Any idea?
I switched the append to html and nothing happens. Maybe it is a scope problem because an Alert($('#btnPlayerName'). html()) returns the expected, but the page does not update (verified through the element inspector).
– Alexandre Bonfá
console.log(lblPN);
Gives the expected result on the browser console you are using?btnPlayerName
is unique ID or is repeated somewhere on the page?– Zuul
It was repeated on every page and that was the problem!!!
– Alexandre Bonfá
what version of jQM are using?
– Omar