Because we want to be able to enter items in the main text field, let's create a binding form that form-inputs to our TaskService.cfc
.
1. Add the following code to
index.cfm
; this will bind the text field to theTaskService.cfc:
<!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="main.css" type="text/css"> <title>Todo</title> <cfajaxproxy bind="cfc:todo.TaskService.addTodo({taskname})" onSuccess="displayTodos" onError="onError"/> <script type="text/javascript" charset="utf-8"> onError = function(code,message){ alert(code + ' - ' + message); } displayTodos = function (data){ document.getElementById('taskname').value = ""; } </script> </head> <body> <div id="page"> <h1 id="todo">Todo</h1> <input type="text" name="taskname" id="taskname" placeholder="What do you need to do?"> </div> <cfdump var="#SESSION.TASKS#"> </body...