jquery - Reflow table generated in loop not responsive -


i generating reflow table in loop in jquery mobile after ajax success. problem table not responsive. on small screens table generated supposed work collapsing table columns stacked presentation looks blocks of label/data pairs each row. when output table markup generate loop , copy/paste separate page, table looks fine , responsive.

the html generate is:

<table data-role="table" id="time-table" data-mode="reflow" class="ui-responsive table-stroke">     <thead>        <tr>          <th>linje</th>          <th>destination</th>          <th>nästa tur (min)</th>          <th>därefter</th>        </tr>     </thead>     <tbody>        <tr>          <th>7</th>          <td>resecentrum</td>          <td>nu</td>          <td>11</td>        </tr>        <tr>          <th>7</th>          <td>Ö lugnet via resecentrum</td>          <td>23</td>          <td>51</td>        </tr>     </tbody> </table> 

looks in small screen when copy markup generated , paste in separate file , what need.

enter image description here

however when dynamically code:

success: function(data){     //generate table header , populate. var thdata1 = "<th>"+data[2]+"</th>"; var thdata2 = "<th>"+data[3]+"</th>"; var thdata3 = "<th>"+data[4]+"</th>"; var thdata4 = "<th>"+data[6]+"</th>";      var tblrow = $("<tr></tr>"); var thead = $("<thead></thead>"); var table = $("<table data-role=\"table\" id=\"time-table\" data-mode=\"reflow\" class=\"ui-responsive table-stroke\">");  tblrow.append(thdata1); tblrow.append(thdata2); tblrow.append(thdata3); tblrow.append(thdata4);      thead.append(tblrow); table.append(thead)      //generate table body , populate. var row = $("<tr>"); var flag = 0; var tbody = $('<tbody>'); $.each(data, function(key, val){     if(key >= 8){     if(key%4 != 3){       if(flag == 0)         row.append("<th>"+val+"</th>");       else         row.append("<td>"+val+"</td>");       flag++;     }     else if(key%4 == 3){       row.append("<td>"+val+"</td>");       tbody.append(row);       row = $("<tr>");       flag = 0;     }      }      });    table.append(tbody);    table.appendto("#contbl");    console.log($("#contbl").html()); } 

it generates normal layout unresponsive table in image below retains same structure in smaller screen. css looks out of place in layout. using default table class="ui-responsive table-stroke" provided jqm.

enter image description here

the markup generate working fine. cannot figure out problem here.

when create dynamically html in case have update page content using

$('page_id').trigger('pagecreate'); 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -