I'm not too sure as to the cause. But this is how I would re-write what you are doing (which appears to fix the problem):
Firstly, remove your inline javascript (onclick="toggleChecked('2', 'TR02')"
) from the HTML.
Next, replace your toggleChecked()
function with the following javascript:
$(document).ready(function(){
$('a[id^="star"]').on("click", function(){
if ($(this).data("theme") == "d") {
$(this).buttonMarkup({ theme: 'e' }).button();
} else {
$(this).buttonMarkup({ theme: 'd' }).button();
}
});
});
The above is an event listener, that will check to see when any anchor with an id
starting with star
is clicked.
Refreshing the button appears to be a bit buggy, often classes from the previous theme hang around despite rebuilding the button.
UPDATE
Actually scrap the above, it seems like such a convoluted way of achieving a selected button. Why not just change the CSS, using the above as a guide, remove the inline styles and use the following jQuery:
$(document).ready(function(){
$('a[id^="star"]').on("click",function(){
$(this).toggleClass("ui-btn-pressed");
});
});
Here is a jsbin: http://jsbin.com/ifodij/8/edit