twitter bootstrap动态生成的表没有响应

时间:2014-04-08 11:40:32

标签: javascript jquery html twitter-bootstrap

我的Twitter引导表是响应式的。当他们将屏幕垂直转动时,这对于Ipad访问是必要的。在一种情况下,表由Javascript生成。当发生这种情况时,这个特定的表不再响应。有解决方案吗?

代码javascript:

var div = $('#mijn_abonnement table');
    var table = '<thead><tr><th>Module</th><th>Aantal</th><th>Maandprijs</th><th></tr></thead>'+
                    '<tbody>';
                    var total = 0;
                    $.each(data, function( index, item ) {
                        var price = parseFloat(item.realprice);
                        if(!isNaN(price)){
                            total = total + price;
                        }
                        if(item.prijs != '0,00'){                                   
                            table += '<tr>';
                                table += '<td>'+item.naam+'</td>';
                                table += '<td>'+item.counter+'</td>';
                                table += '<td>'+accounting.formatMoney(item.one_prijs, "€ ", 2, ".", ",")+'</td>';
                                table += '<td>'+accounting.formatMoney(item.realprice, "€ ", 2, ".", ",")+'</td>';
                            table += '</tr>';
                        }
                    });
                    table += '<tr class="success"><td></td><td></td><td align="right"><b>Subtotaal (ex.BTW)</b></td><td>'+accounting.formatMoney(total, "€ ", 2, ".", ",")+'</td></tr>';
                    table += '<tr class="success"><td></td><td></td><td align="right"><b>BTW (21%)</b></td><td>'+accounting.formatMoney(total * 0.21, "€ ", 2, ".", ",")+'</td></tr>';
                    table += '<tr class="success"><td></td><td></td><td align="right"><b>Totaal</b></td><td>'+accounting.formatMoney(total * 1.21, "€ ", 2, ".", ",")+'</td></tr>';
           table += '</tbody>';
    div.append(table);

代码HTML:

        <div id="mijn_abonnement">  
            <table class="table table-striped table-bordered table-responsive"></table>
        </div>

1 个答案:

答案 0 :(得分:0)

试试这个......

var div = $('#mijn_abonnement');
        var table = '<table class='table table-striped table-bordered table-responsive'><thead><tr><th>Module</th><th>Aantal</th><th>Maandprijs</th><th></tr></thead>'+
                        '<tbody>';
                        var total = 0;
                        $.each(data, function( index, item ) {
                            var price = parseFloat(item.realprice);
                            if(!isNaN(price)){
                                total = total + price;
                            }
                            if(item.prijs != '0,00'){                                   
                                table += '<tr>';
                                    table += '<td>'+item.naam+'</td>';
                                    table += '<td>'+item.counter+'</td>';
                                    table += '<td>'+accounting.formatMoney(item.one_prijs, "€ ", 2, ".", ",")+'</td>';
                                    table += '<td>'+accounting.formatMoney(item.realprice, "€ ", 2, ".", ",")+'</td>';
                                table += '</tr>';
                            }
                        });
                        table += '<tr class="success"><td></td><td></td><td align="right"><b>Subtotaal (ex.BTW)</b></td><td>'+accounting.formatMoney(total, "€ ", 2, ".", ",")+'</td></tr>';
                        table += '<tr class="success"><td></td><td></td><td align="right"><b>BTW (21%)</b></td><td>'+accounting.formatMoney(total * 0.21, "€ ", 2, ".", ",")+'</td></tr>';
                        table += '<tr class="success"><td></td><td></td><td align="right"><b>Totaal</b></td><td>'+accounting.formatMoney(total * 1.21, "€ ", 2, ".", ",")+'</td></tr>';
               table += '</tbody></table>';
               div.innerHTML(table);

HTML代码

<div id="mijn_abonnement">  </div>