dt-list

0.1.4 • Public • Published

Δt dynamictemplate List Controller

This provides List handling support for asyncxml and Δt.

Installation

$ npm install dt-list

Usage

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();
    });
}

Example in detail.

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.

Package Sidebar

Install

npm i dt-list

Weekly Downloads

2

Version

0.1.4

License

none

Last publish

Collaborators

  • dodo