javascript - How can I refresh a table that contains JQuery mobile buttons without losing formatting -
i have created function generates table of jquery mobile buttons; using javascript (this called in document ready function), using following code - works fine:
function renderbuttons() { console.log(coaches); var coachbuttonshtml = ""; coachbuttonshtml += "<table align='center' class='full_width_table'>" + "<tr>" + "<td class='cellpadding'><div id='0' data-role='button' data-position-to='window' data-mini='true' onclick='coachselect(this.id)'>coach " + "(" + coaches[0].value + ")" + "</div></td>" + "<td class='cellpadding'><div id='1' data-role='button' data-position-to='window' data-mini='true' onclick='coachselect(this.id)'>coach b " + "(" + coaches[1].value + ")" + "</div></td>" + "<td class='cellpadding'><div id='2' data-role='button' data-position-to='window' data-mini='true' onclick='coachselect(this.id)'>coach c " + "(" + coaches[2].value + ")" + "</div></td>" + "</tr>" + "<tr>" + "<td class='cellpadding'><div id='3' data-role='button' data-position-to='window' data-mini='true' onclick='coachselect(this.id)'>coach d " + "(" + coaches[3].value + ")" + "</div></td>" + "<td class='cellpadding'><div id='4' data-role='button' data-position-to='window' data-mini='true' onclick='coachselect(this.id)'>coach e " + "(" + coaches[4].value + ")" + "</div></td>" + "<td class='cellpadding'><div id='5' data-role='button' data-position-to='window' data-mini='true' onclick='coachselect(this.id)'>coach f " + "(" + coaches[5].value + ")" + "</div></td>" + "</tr>" + "</table>"; $('#coach_buttons').append(coachbuttonshtml).trigger('create'); }
the problem updating values within buttons in different function, , trying update buttons calling render function - renderbuttons();
. leads problem of having 2 sets of buttons.
so tried using line of code "update" table:
$('#coach_buttons').append(coachbuttonshtml).trigger('update');
using code renders button values, there no formatting (its text no button).
does know of way around this?
i fixed using following line of code -
$('#coach_buttons').html(coachbuttonshtml).trigger('create');
this means doesn't create duplicates , keeps formatting replaces html, whereas other 1 added it.
Comments
Post a Comment