0.1.4 • Published 11 years ago
dt-list v0.1.4
Δt dynamictemplate List Controller
This provides List handling support for asyncxml and Δt.
Installation
$ npm install dt-listUsage
var List = require('dt-list').List; // server
var List = dynamictemplate.List; // browser
function myTemplate(view) {
var that = this;
var items = new List;
view.on('add', function (model) {
items.push(that.$li(function () {
this.$p(model.text);
}));
});
view.on('insert', function (i, model) {
items.insert(i, that.$li(function () {
this.$p(model.text);
}));
});
view.on('remove', function (i) {
var el;
if (typeof i === 'undefined')
el = items.remove(i);
else
el = items.shift();
if (el) el.remove();
});
}api
Same api like Order but you don't have to give functions anymore, that does List for you. Just throw your Δt elements created with asyncxml into the List like your would throw values into javascripts Array.