Skip to content

Instantly share code, notes, and snippets.

@wvengen
Last active December 24, 2015 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wvengen/6784056 to your computer and use it in GitHub Desktop.
Save wvengen/6784056 to your computer and use it in GitHub Desktop.
listjs templateEngine adding a css class instead of removing rows; based on JuliusR's work, see https://github.com/foodcoops/foodsoft/pull/180
// for use with listjs 0.2.0
// https://github.com/javve/list.js
// PROBABLY UNFINISHED CODE
List.prototype.templateEngines.unlist = function(list, settings) {
var h = window.ListJsHelpers;
// start with standard engine, override specific methods afterwards
this.superClass = List.prototype.templateEngines.standard;
this.superClass(list, settings);
// todo refer to listjs code instead of copy-pasting
var listSource = h.getByClass(settings.listClass, list.listContainer, true);
var templater = this;
var ensure = {
created: function(item) {
if (item.elm === undefined) {
templater.create(item);
}
}
};
this.show = function(item) {
ensure.created(item);
$(item.elm).removeClass('unlisted');
};
this.hide = function(item) {
ensure.created(item);
$(item.elm).addClass('unlisted');
};
this.clear = function() {
$(listSource.childNodes).addClass('unlisted');
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment