If you remember, in the TaskService.cfc
template, we have a function called removeTodo()
that takes the position of the task in our array and deletes it. Let's connect a JavaScript function to this server-side function:
1. In the
index.cfm
template, let's add another<cfajaxproxy>
tag. This time it will bind theTaskService.cfc
to a JavaScript variable:<head> <link rel="stylesheet" href="main.css" type="text/css"> <title>Todo</title> <cfajaxproxy bind="cfc:todo.TaskService.addTodo({taskname})" onSuccess="displayTodos" onError="onError"/> <cfajaxproxy cfc="todo.TaskService"" jsclassname="TaskService">
2. In the previous code, we have used the
<cfajaxproxy>
tag again, but this time we are using thecfc="todo.TaskService"
attribute to say which component we want to bind to a new JavaScript object. We then use thejsclassname="TaskService"
attribute to set its name.3. Now that we have bound it to a new object...