Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在可移动重新加载或重新绘制时重置分页_Javascript_Jquery_Footable - Fatal编程技术网

Javascript 在可移动重新加载或重新绘制时重置分页

Javascript 在可移动重新加载或重新绘制时重置分页,javascript,jquery,footable,Javascript,Jquery,Footable,我目前正在开发一个web应用程序,它将在表中显示数据 对于本应用程序的一部分,我们列出了某些应用程序的当前状态。如果单击表中的一个应用程序,ajax调用将获取数据库中应用程序的ID,并提取该应用程序的所有状态列表及其日期 虽然这一切都很好,但我们的问题是以分页的形式出现的。如果导航到第一个表的第二页,即包含每个应用程序当前状态的表,并单击具有五个以上状态列表的应用程序(我们的数据页大小限制为5),则第二个表将从第二个数据页开始 当导航回第一页工作时,表中的数据仍然正确显示,这是一个我们不希望出现

我目前正在开发一个web应用程序,它将在表中显示数据

对于本应用程序的一部分,我们列出了某些应用程序的当前状态。如果单击表中的一个应用程序,ajax调用将获取数据库中应用程序的ID,并提取该应用程序的所有状态列表及其日期

虽然这一切都很好,但我们的问题是以分页的形式出现的。如果导航到第一个表的第二页,即包含每个应用程序当前状态的表,并单击具有五个以上状态列表的应用程序(我们的数据页大小限制为5),则第二个表将从第二个数据页开始

当导航回第一页工作时,表中的数据仍然正确显示,这是一个我们不希望出现的问题。我们要做的是让分页在重新加载表时自动显示结果的第一页

到目前为止,我们尝试的是为footable找到一个页面重置触发器,尝试将表页脚中的第一个页面项作为目标,并执行.click(由于它是如何生成的,我们找不到一种方法来将其作为目标),重新初始化表,并在footable javascript文件中找到一个我们可以使用的预制函数

我想知道的是,有没有办法将分页设置为在表格重画时显示第一页

目前,我们正在重新绘制该表以修复另一个分页问题

当前代码:

function getAppStats(id) {
        $.ajax({
            Async: false,
            url: '@Url.Action("GetAppStatusList", "Application", Nothing, Request.Url.Scheme)',
            type: 'POST',
            data: { id: id },
            success: function (data) {
                var label = "" 

                //The headers change on the new table, so I need to change the headers dynamically
                var newHTML = "<thead><tr><th data-toggle=\"true\">Application</th><th>Application ID</th><th>Date</th><th>Status</th></tr></thead><tbody>"

               //Iterating through the list of statuses, and if it's not one of three values, assigning an on-click to display more data.
                $(data).each(function (index, item) {
                    if (item.status != "Created Date" && item.status != "Inactivated" && item.status != "Active"){
                        newHTML = newHTML + "<tr id=\"" + item.appId + "\" onclick=\"getDeployComments(" + item.typeId + ", " + item.appId + ")\"><td id=\"app\">" + item.name + "</td><td>" + item.appId + "</td><td id=\"date\">" + item.date + "</td><td id=\"stat\">" + item.status + "</td></tr>"
                    } else {
                        newHTML = newHTML + "<tr id=\"" + item.appId + "\"><td id=\"app\">" + item.name + "</td><td>" + item.appId + "</td><td id=\"date\">" + item.date + "</td><td id=\"stat\">" + item.status + "</td></tr>"
                    }

                    label = item.name + " Deployment History"
                })
                newHTML = newHTML + "</tbody><tfoot class=\"hide-if-no-paging\"><tr><td colspan=\"5\"><div class=\"pagination pagination-centered list-inline list-inline\"></div></td></tr></tfoot>"

                $('#appTable').html(newHTML)

                //There's other HTML adding here, but it has nothing to do with the problem at hand.

                $('table').trigger('footable_redraw'); //Redrawing the table to fix an issue we had with pagination not showing at all.
            },
            error: function () {

            }
        })
    }
函数getAppStats(id){ $.ajax({ Async:false, url:'@url.Action(“GetAppStatusList”,“Application”,Nothing,Request.url.Scheme)”, 键入:“POST”, 数据:{id:id}, 成功:功能(数据){ var label=“” //新表上的标题会更改,因此我需要动态更改标题 var newHTML=“ApplicationApplicationIDDateStatus” //遍历状态列表,如果不是三个值中的一个,则分配单击以显示更多数据。 $(数据)。每个(功能)(索引,项目){ 如果(item.status!=“创建日期”&&item.status!=“未激活”&&item.status!=“活动”){ newHTML=newHTML+“”+item.name+“”+item.appId+“”+item.date+“”+item.status+“” }否则{ newHTML=newHTML+“”+item.name+“”+item.appId+“”+item.date+“”+item.status+“” } label=item.name+“部署历史记录” }) newHTML=newHTML+“” $('#appTable').html(newHTML) //这里添加了其他HTML,但这与当前的问题无关。 $('table').trigger('footable_redraw');//重新绘制表以修复分页根本不显示的问题。 }, 错误:函数(){ } }) }
一种解决方案是通过数据属性将第一个页面链接作为目标,并触发点击事件:

$('.footable-page a').filter('[data-page="0"]').trigger('click');

FooTable
redraw
事件会创建分页元素,因此请确保这是第一个元素。

啊,我还没有想到
.filter
。我现在正在尝试,如果这有效,我会接受你的答案。没问题,jQueryAPI相当大!让我知道它是如何运行的,很高兴迭代直到你的应用程序工作。它工作了,真是太棒了!我要是记得那一个就好了,这样就省去了这个问题的麻烦了。再说一次,其他人现在也没有机会找到这个,以及这个美妙的答案。只有当第一页当前不是活动页时,这才有效。