infinity.js的最佳实践 [英] best practices with infinity.js
问题描述
我正在使用AirBnb的infinity.js插件在我的应用程序中生成无限列表。
I am using AirBnb's infinity.js plugin to generate an infinite list in my app.
我在创建相关页面时第一次生成列表。
但是根据过滤复选框和选择按钮,列表必须更新。
所以我必须重新生成列表。
鉴于创建我的列表 new infinity.ListView($ el);
是函数 resetModelsListView
,如果我每次想要更新列表时重新启动 resetModelsListView
,它都会创建一个新的列表视图。如何管理这个?
I generate the list the first time on the create of the concerned page.
But then the list has to update depending on filtering checkboxes and select buttons.
So I have to regenerate the list.
Given that the creation of my list new infinity.ListView($el);
is whithin the function resetModelsListView
, if I relaunch resetModelsListView
every time I want to update the list it creates a new listview. How to manage this please ?
function resetModelsListView(prodata, firsttime, funfeatureOn, specificBrand, specificPro) {
...
//create listview
var $el = $('#modelsListview');
var listView = new infinity.ListView($el);
//add new content:
var $newContent = $(optionsmodel); //optionsmodel is a list of <li>s
listView.append($newContent);
}
推荐答案
我不喜欢如果这是好的做法,但是现在我这样做:
I don't if it's good practices, but for now I am doing this :
function resetModelsListView(prodata, firsttime, funfeatureOn, specificBrand, specificPro) {
...
//USING INFINITY.JS:
//clear previous list
if (typeof listView !== 'undefined') {
listView.remove();
listView.cleanup();
}
//reinit the list
var $el = $('#modelsListview');
listView = new infinity.ListView($el);
//adding new content:
var $newContent = $(optionsmodel);
listView.append($newContent);
}
这篇关于infinity.js的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!