I have a JavaScript object
var items = { ids : [
{
label: "red",
complete: true
},
{
label: "green",
complete: false
},
{
label: "blue",
complete: true
}
]
}
I need to filter out based on the complete attribute when I click on the complete button or when I click on all button it show show me all the entries.
How can I do this in the same function
I have this function which takes the list DOM element and creates the entries accordingly. I am wondering how could I write this function such that it could filter on the complete status or print all the entries in the redraw function itself.
var redraw = function(items) {
list.innerHTML='';
for (var id in items) {
draw(model.todos[id], list);
}
};
var draw = function(Obj, container) {
var el = Template.cloneNode(true);
el.setAttribute('data-id', Obj.id);
container.appendChild(el);
update(Obj);
});
}