【问题标题】:footable , how to initialize the filter of a table just after the loading of the pagefootable , 如何在页面加载后初始化表格的过滤器
【发布时间】:2016-02-16 10:44:36
【问题描述】:

我使用出色的插件“footable”来排序和过滤我的表格。

但在某些情况下,我的页面必须使用某个过滤器进行初始化。例如,mu url 是:

myurl/mypage/19

在服务器端,我得到“19”并将其发送到视图。在视图中,我将此值放入输入字段中。

页面加载后如何用这个输入值过滤这个表?

我试过了:

$('table').footable();
$('table').trigger('footable_redraw');

$('table').footable();
$('table').trigger('footable_initialize');

没有成功。

Dom

更新: 我指定过滤器有效。只是在页面加载过程中我在字段中放了一些东西时,过滤器没有初始化。

js代码:

$(document).ready( function() {

    $('table').footable();
    $('table').trigger('footable_initialize');
})

html 代码:

<input class="form-control" id="filter" type="text" placeholder="Rechercher ..." value="{{ $libelle_classe }}">

<table class="table footable table-hover table-bordered"  data-filter="#filter">

【问题讨论】:

  • 您是否尝试将代码放入$(document).ready() 事件中? api.jquery.com/ready
  • 当然,代码在 $(document).ready() 中。像这样: $(document).ready(function() { $('table').footable(); $('table').trigger('footable_initialize');
  • 你能贴出你用来过滤表的代码吗?
  • 我用代码编辑了帖子。谢谢。

标签: footable


【解决方案1】:

一种可能的解决方案是使用输入值手动触发过滤器事件:

$(document).ready( function() {
    $('table').trigger('footable_filter', {
        filter: $("#filter").val()
   });
});

我希望这会有所帮助!

【讨论】:

  • 是的,它适用于您的解决方案。我不知道我们可以这样过滤。我喜欢“脚踏实地”。谢谢。
  • footable.filter.js 中的过滤器事件在 input 的 keyup 事件被触发时被调用。直接分配输入值时不会发生这种情况。我也喜欢“footable”,是一个很棒的插件!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多