【发布时间】:2013-04-24 03:06:39
【问题描述】:
我需要一些关于 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>
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();
});
第一次打开时,此 FooTable 会正确应用。如果我单击主页按钮并返回,然后再次进入该页面,则 FooTable 未正确应用。
截图:
所以我当时面临的问题包括:
显示隐藏字段。 (意味着不应用Footable): 在设备中更改方向两次后,此问题得到解决。
第一个字段不再包含“数据展开”按钮(表示未应用Footable):
我认为问题在于我要删除旧行并添加新行。我试过没有给删除电话。那时,旧行正在正确显示。如屏幕截图所示,新附加的字段存在问题。
有人可以帮我解决这个问题吗?
P.S: 我在 android webview 中渲染这个。同样的问题也在浏览器中重现。
【问题讨论】:
-
我能知道投反对票的原因吗?在作为问题发布之前,我已经尽力在谷歌上搜索
-
您使用的是哪个版本的 jquery 和 JQM?
.live已折旧并替换为.on。另外,请尝试在附加项目$('[data-role=page]').trigger('create')后添加它。 -
@Omar jQM 版本 1.2.0。
.on没用。我尝试在附加数据后添加$('[data-role=page]').trigger('create')。但这并没有改变什么。 -
如果您使用的是 jquery 1.8.3 及更高版本,
.on应该可以工作。在$('#tblSRNDetails').footable();之后添加trigger('create')了吗?试试refresh或pagecreate而不是create。 -
是的,@Omar。我在
$('#tblSRNDetails').footable();之后添加了触发器并尝试刷新和页面创建两者。还是一样的输出。有什么办法可以去除脚感/刷新它?
标签: android jquery jquery-mobile jquery-plugins footable