Sprint 1 – addListItem function

Add List Item (on-click) event handler

When the user clicks the Add button the addListItem function is invoked, but rather than adding a new Task to the list, this function makes the facility to create a new Task available.

function addListItem() {
 var objTextArea = document.getElementById('listItemTextArea');
 objTextArea.value = '';

 var objHighlightedItem = document.querySelector('.highlighted');

 if (!!objHighlightedItem) {
   objHighlightedItem.className = objHighlightedItem.className.replace(/highlighted/, "lowLight");

  1. Much like the earlier functions, the addListItem function begins by locating the TextArea and selected Task from the list.
  2. The function removes any data from the TextArea as we are creating a new Task not editing an existing Task.
  3. Any selected Task is de-selected and its entry in the Task List is ‘lowLight’-ed.
  4. The Task Details panel is displayed using the showFunctions call and the TextArea is given focus.

Return to the Sprint One section.
Return to the main article.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s