Full featured list build for mobile first, while design ignorant.
- Optional iscroll, pull-to-refresh and more
- Reactive support by reactive-lite
- Sort and filter data on remote/local mode
- Event delegate for better performance
npm i mobile-list
var List = require('mobile-list')
var template = require('./template.html')
var list = new List(template, window, {
selector: 'ul.mylist'
})
api.loadUsers(function(err, arr) {
list.setData(arr)
})
sort
emit with params when remote sort needed (includingsortField
sortDirection
)filter
emit with params when remote filter needed (includingfilterField
filterValud
)page
emit with params when remote paging needed (includingcurpage
,perpage
)remove
emit just before this component removed
template
template string or element for repeat renderscrollable
the scrollable elementoption
optional option for list-renderoption.perpage
max page count perpage for paging, works with pageroption.selector
selector for parentNode of repeat template, defaultul
option.delegate
delegate object for reactiveoption.bindings
bindings object for reactiveoption.filters
filters object for reactiveoption.model
model class used for generate modeloption.empty
String or Element rendered in parentNode when internal data list is emptyoption.limit
the limit number for render whensetData()
(default no limit)option.moreCount
works withoption.limit
it limit count of items to render with.more(n)
method when last item visible on scroll, default 10option.autoHeight
set the height of parentNode even if data not rendered (need limit to work, items should have same height)
List inherits all methods from list-render, the extra methods are shown below
Use iscroll for smooth scrolling, set option.handlebar
to true if your want handlebar to show
options
is pull-to-refresh options, which may have texts or/and templatecallback
should return a promise which resolve an array of data(or reject error) for rendercallback
is called with additional parampullTimestamp
which contains time stamp of latest succeed pull.
Use more for loading more data,
callback should return promise which resolve an array of data(or reject error) for render
Delegate event type
to selector
with handler
,
handler is called with event and a reactive model
Make list works on local model, which means sort, filter and paging only happens locally
Sort the data by field, direction or method, when it's remote mode(default mode), emit event only
Filter the data by field, val or function, when it's remote mode(default mode), emit event only
Let pull-to-refresh to refresh more data
Set total data count for paging, can not used for local mode
Remove all rendered repeat elements and unbind all events