Android 添加动态数据时footable中的问题
我需要一些jQuery手机方面的帮助。 我正在表中动态添加数据 HTML:Android 添加动态数据时footable中的问题,android,jquery,jquery-mobile,jquery-plugins,footable,Android,Jquery,Jquery Mobile,Jquery Plugins,Footable,我需要一些jQuery手机方面的帮助。 我正在表中动态添加数据 HTML: SRN 失效日期 投诉报告日期 约定日期 客户名称 记录时间 创建FSR 开放日 SRN分配的时间 SRN状态 ESN编号 请求类型 服务请求详细信息 js代码: $("#page-id").live('pagebeforeshow', function() { console.log("Page before show"); $("#tblSRNDetails > tbody tr").rem
SRN
失效日期
投诉报告日期
约定日期
客户名称
记录时间
创建FSR
开放日
SRN分配的时间
SRN状态
ESN编号
请求类型
服务请求详细信息
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();
});
$(“#页面id”).live('pagebeforeshow',function(){
控制台日志(“显示前的页面”);
$(“#tblSRNDetails>tbody tr”).remove();
对于(var indx=0;indx<2;indx++)
{
$(“#tblSRNDetails>tbody”)。追加(“”+
“姓名”+
“失效日期”+
“投诉报告日期”+
“承诺人”+
“客户名称”+
""+
“创建FSR”+
“daysOpen”+
“分配的时间”+
“srn_状态”+
“ESNNumber”+
“请求类型”+
“客户投诉”+
"");
}
$('tblSRNDetails').footable();
});
首次打开时,可正确使用此脚踏板。如果我点击主页按钮并返回,然后再次进入该页面,则脚踏板应用不正确
截图:
因此,我当时面临的问题包括:
$(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(){
});
$(document).on('pageshow','#index',function(){
$(“#tblSRNDetails”).remove();
$('').attr({'id':'tblSRNDetails','class':'footable'}).appendTo('[data role=“content”]');
$(“#tblSRNDetails”)。追加(
""+
“SRN”+
“故障日期”+
“投诉报告日期”+
“承诺日期”+
“客户名称”+
“记录时间”+
“创建FSR”+
“开放日”+
“SRN分配的时间”+
“SRN状态”+
“ESN编号”+
“请求类型”+
“服务请求详细信息”+
"");
对于(var indx=0;indx<2;indx++)
{
$(“#tblSRNDetails”)。追加(
""+
“姓名”+
“失效日期”+
“投诉报告日期”+
“承诺人”+
“客户名称”+
""+
“创建FSR”+
“daysOpen”+
“分配的时间”+
“srn_状态”+
“ESNNumber”+
“请求类型”+
“客户投诉”+
"");
}
$('tblSRNDetails').footable();
});
$(document).on('pagebeforeshow','#second',function(){
});
我在web应用程序中遇到了同样的问题,我在datatables.net回调中使用了这个问题,我添加了footable的redraw函数,它工作得非常好
$('table').trigger('footable_redraw');
“Footable”与“jQuery Mobile”配合使用效果很好。我将用我的代码片段解释它的用法 可脚踏初始化
function initFootable() {
$(function () {
$('.footable').footable({ //.footable is my class for table
breakpoints: {
phone: 480, //Breakpoint width for phones
tablet: 1024 //Breakpoint width for tablets
}
});
});
}
我使用jqueryajax调用获取新的表数据,并使用模板方法将它们添加到表中。我正在使用handlebar.js作为模板。(请记住,此模板方法不是强制性的。您可以使用自己的方法将新行追加到表中。)
因此,在将新数据更新到表中后,需要触发footable进行重新初始化。下面是代码片段
function updateFootable() {
var paramTable = $('.footable');
paramTable.footable();
paramTable.trigger('footable_initialize'); //Reinitialize
paramTable.trigger('footable_redraw'); //Redraw the table
paramTable.trigger('footable_resize'); //Resize the table
}
这里的所有触发器都不是必需的。根据您在重新初始化/重绘/调整大小时遇到的问题,检查并确认调用哪个触发器对您刚好足够
就这样,现在在jQuery Mobile中使用footable不会有任何问题
重要提示:但是,在调用updateFootable()时必须小心,如果包含该表的div或包含该表的页面被隐藏,则不会相应地调整该表的大小。在调用表的更新时,必须确保该表可见
链接:
这是脚踏触发器的文档-
确保通过可步行文档-
我能知道否决票的原因吗?在发布问题之前,我已经尽了最大努力在谷歌上搜索,你使用的JQM是哪个版本的jquery
.live
被折旧并替换为上的。另外,请尝试在附加项$(“[data role=page]”)后添加此项。触发器('create')
@Omar jQM version 1.2.0<代码>.on
不起作用。我尝试添加$('[data role=page]')。在添加数据后触发('create')
。日分
function updateFootable() {
var paramTable = $('.footable');
paramTable.footable();
paramTable.trigger('footable_initialize'); //Reinitialize
paramTable.trigger('footable_redraw'); //Redraw the table
paramTable.trigger('footable_resize'); //Resize the table
}