我有与渲染函数中的模板创建DataTable的行查看:刷新一个jQuery的dataTable
render: function(){
this.collection.fetch({async:false});
var tmpl = _.template(this.template);
var that = this;
_.each(this.collection.toJSON(), function(item) {
$(that.el).append(tmpl(item));
});
return this;
},
这之后,我初始化数据表是这样的:
$("#idTable").dataTable();
我有另一种观点,修改/添加集合调用模型后,再次渲染该数据表的重绘。 修改/添加的行在表格中正确显示,但如果使用分页或搜索框,修改/添加的行会消失并显示旧的行。
如何刷新数据表?
我发现只有这样:How do I tell dataTables to check for updated data in a backbone collection?,但我需要使用Undercore的模板创建数据表。
我看过了,但大家都在谈论fnReloadajax。在我的情况下,它不,我猜是因为我使用下划线模板构建表格,而不是像这样:$(“#example”)。dataTable({“{”sTitle“:”Id“}) , { “sTitle”: “姓名”}], “bProcessing”:真实, “bServerSide”:真实, “sAjaxSource”: '@ Url.Action( “FetchData”, “家”)' , “sPaginationType”:“full_numbers”, }); – riccio82 2013-05-09 22:09:34