not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

41 lines
1.3 KiB

define(function (require) {
var view = {};
view.View = function () {
this.template =
'<li data-id="{{id}}" class="{{completed}}" draggable="true" ondragstart="drag(event)" ondragover="allowDrop(event)" ondrop="drop(event)">' +
'<div class="view">' +
'<input class="toggle" type="checkbox" {{checked}}>' +
'<label>{{title}}</label>' +
'<button class="remove"></button>' +
'</div>' +
'</li>';
};
// Create a string of HTML <li> elements inside with the given
// items.
view.View.prototype.show = function (items) {
var i, l;
var view = '';
for (i = 0, l = items.length; i < l; i++) {
var template = this.template;
var completed = '';
var checked = '';
if (items[i].completed === 1) {
completed = 'completed';
checked = 'checked';
}
template = template.replace('{{id}}', items[i].id);
template = template.replace('{{title}}', items[i].title);
template = template.replace('{{completed}}', completed);
template = template.replace('{{checked}}', checked);
view = view + template;
}
return view;
};
return view;
});