添加动态数据时在footable问题

Mys*_*icϡ 8 jquery android jquery-plugins jquery-mobile footable

我需要在jQuery Mobile Foo Table中提供一点帮助.我在表中动态添加数据.

HTML:

    <table id="tblSRNDetails" class="footable">
        <thead>
            <tr>
                <th data-class="expand">SRN</th>
                <th >Failure Date</th>  
                <th >Complaint Report Date</th>                 
                <th>Promised Date</th>  
                <th >Customer Name</th>
                <th >Log Time</th>
                <th >Create FSR</th>    
                <th  data-hide="phone,tablet">Days Open</th>        
                <th  data-hide="phone,tablet">SRN Allocated Time</th>   
                <th  data-hide="phone,tablet"> SRN Status</th>  
                <th  data-hide="phone,tablet"> ESN Number</th>  
                <th  data-hide="phone,tablet"> Request Type</th>    
                <th  data-hide="phone,tablet">Service Request Details</th>                          
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
Run Code Online (Sandbox Code Playgroud)

js代码:

$("#page-id").live('pagebeforeshow', function() {
    console.log("Page before show");
    $("#tblSRNDetails > tbody tr").remove();
    for (var indx = 0; indx < 2; indx++ )
    {
        $("#tblSRNDetails > tbody").append("<tr>"+
        "<td>Name</td>"+
        "<td>failureDate</td>"+
        "<td>complaintReportDate</td>"+
        "<td>promisedDate</td>"+
        "<td>custName</td>"+
        "<td><a href='#'><b>Log Time</b></a></td>"+
        "<td><b>Create FSR</b></td>"+
        "<td>daysOpen</td>"+
        "<td>allocatedTime</td>"+
        "<td>srn_status</td>"+
        "<td>ESNNumber</td>"+
        "<td>requestType</td>"+
        "<td>customerComplaint</td>"+
        "</tr>");   
    }
    $('#tblSRNDetails').footable();
});
Run Code Online (Sandbox Code Playgroud)

使用此FooTable在第一次打开时正确应用.如果我单击主页按钮然后返回,再次进入该页面,则FooTable未正确应用.

截图:

在此输入图像描述

所以我当时面临的问题包括:

  1. 隐藏字段显示.(表示未应用Footable):在设备中更改方向两次后,此问题得到解决.

  2. 第一个字段不再包含"数据展开"按钮(不应用"可以使用句子"):

我认为问题是因为我删除了旧行并添加了新行.我试过没有给删除电话.那时,旧行正在正确显示.新增的字段存在问题,如屏幕截图所示.

有人可以帮我弄这个吗?

PS:我在android webview中呈现这个.同样的问题也在浏览器中再现.

Gaj*_*res 4

Foo 表是作为 jQuery 插件创建的,因此从未打算与 jQuery Mobile 一起使用。它只是另一个无法在 jQuery mobile 上正常工作的插件。Foo 表不知道如何处理 jQuery Mobile 页面切换。

使其发挥作用的唯一方法是每次访问该页面时动态创建整个表。在任何其他情况下,Foo 表都将不起作用,因为页面已经存在并具有增强的表标记。这就是为什么每个 jQuery Mobile 小部件都有一个带有刷新属性的函数。

这是一个工作示例:http://jsfiddle.net/Gajotres/PjmEL/

最后一件事,如果这对您来说不是一个好的解决方案,您应该切换到动态表的 jQuery Mobile 实现。

$(document).on('pageshow', '#index', function(){  
    $("#tblSRNDetails").remove();
    $('<table>').attr({'id':'tblSRNDetails','class':'footable'}).appendTo('[data-role="content"]');
        $("#tblSRNDetails").append(
            "<thead><tr>"+
            "<th data-class='expand'>SRN</th>"+
            "<th >Failure Date</th>"+
            "<th >Complaint Report Date</th>"+
            "<th>Promised Date</th>"+
            "<th >Customer Name</th>"+
            "<th >Log Time</th>"+
            "<th >Create FSR</th>"+
            "<th  data-hide='phone,tablet'>Days Open</th>"+
            "<th  data-hide='phone,tablet'>SRN Allocated Time</th>"+
            "<th  data-hide='phone,tablet'> SRN Status</th>"+
            "<th  data-hide='phone,tablet'> ESN Number</th>"+
            "<th  data-hide='phone,tablet'> Request Type</th>"+
            "<th  data-hide='phone,tablet'>Service Request Details</th>"+
            "</tr></thead>");  
    for (var indx = 0; indx < 2; indx++ )
    {
        $("#tblSRNDetails").append(
            "<tbody><tr>"+
            "<td>Name</td>"+
            "<td>failureDate</td>"+
            "<td>complaintReportDate</td>"+
            "<td>promisedDate</td>"+
            "<td>custName</td>"+
            "<td><a href='#'><b>Log Time</b></a></td>"+
            "<td><b>Create FSR</b></td>"+
            "<td>daysOpen</td>"+
            "<td>allocatedTime</td>"+
            "<td>srn_status</td>"+
            "<td>ESNNumber</td>"+
            "<td>requestType</td>"+
            "<td>customerComplaint</td>"+
            "</tr></tbody>");   
    }
    $('#tblSRNDetails').footable();
});

$(document).on('pagebeforeshow', '#second', function(){       

});
Run Code Online (Sandbox Code Playgroud)