this is a todolist js code. Want to know why the append here is not available
here is all the current code link description
;(function () {
"use strict";
var $submit_task = $(".submit-task")
, task_list ={}
;
init();
$submit_task.on("click",function(e){
var new_task = {};
//
e.preventDefault();
// task
new_task.content= $(this).prev(find("input[name=content]")).val();
// task
if(!new_task.content) return ;
// task
if(add_task(new_task)){
render_task_list();
}
})
function add_task(new_task){
//tasktasklist
task_list.push(new_task);
// localStorage
store.set("task_list",task_list);
console.log("task_list",task_list);
}
function init(){
task_list = store.get(".task-list")||[];
if(task_list.length)
render_task_list();
}
function render_task_list(){
var $task_list= $(".task-list");
$task_list.html("");
for( var i = 0 ; i < task_list.length ; iPP)
{
var $task = render_task_tpl(task_list[i]);
$task_list.append($task);
}
}
function render_task_tpl(data){
var list_item_tpl =
"<div class="task-item">"+
"<span><input type="checkbox"></span>"+
"<span class="task-content">"+data.content+"</span>"+
"<span class="action"> </span>"+
"<span class="action"> </span>"+
"</div>";
return $(list_item_tpl);
}
})();