Because we have to reload the page to show our tasks. Let's do this automatically? This is really simple. But First, let's create a page that displays the tasks:
1. Create a template named
displayTasks.cfm
and save it in thetodo
folder.2. In the
displayTasks.cfm
template, add the following simple loop code:<ul id="taskList"> <cfloop array="#SESSION.tasks#" index="task"> <li><cfoutput>#task.NAME#</cfoutput></li> </cfloop> </ul>
3. The previous code simply loops through the items in the
SESSION.tasks
array and displays them in an unordered list.4. If we now go to
http://localhost:8888/todo/displaytasks.cfm
, we can see the output from the session:5. Now that we have something to display, we can integrate it into the main
index.cfm
template. Let's add another AJAX tag to display the contents ofdisplayTask.cfm
; change the main part of your code to add the<cfdiv>
tag:<div id="page"> <h1...