list_render: Return data if no arguments present.

This will return the active data set if no arguments are provided to
the `data` method.
This commit is contained in:
Brock Whittaker 2017-10-08 15:48:13 -07:00 committed by Tim Abbott
parent ae139a78b8
commit 6d8a8f2b7c
1 changed files with 7 additions and 0 deletions

View File

@ -121,6 +121,13 @@ var list_render = (function () {
// initializing a new progressive list render instance, you can just // initializing a new progressive list render instance, you can just
// update the data of an existing one. // update the data of an existing one.
data: function (data) { data: function (data) {
// if no args are provided then just return the existing data.
// this interface is similar to how many jQuery functions operate,
// where a call to the method without data returns the existing data.
if (typeof data === "undefined" && arguments.length === 0) {
return meta.list;
}
if (Array.isArray(data)) { if (Array.isArray(data)) {
meta.list = data; meta.list = data;