examples/todo/js/modules/header.js
function(event, element, elementType) {

			// code to be run when a click occurs
			if (elementType === 'new-todo-input') {

				if (event.keyCode === ENTER_KEY) {

					var todoTitle = (element.value).trim();

					if (todoTitle.length) {
						var newTodoId = todosDB.add(todoTitle);

						context.broadcast('todoadded', {
							id: newTodoId
						});

						// Clear input afterwards
						element.value = '';
					}

					event.preventDefault();
					event.stopPropagation();
				}

			}

		}
function(event, element, elementType) {

			// code to be run when a click occurs
			if (elementType === 'new-todo-input') {

				if (event.keyCode === ENTER_KEY) {

					var todoTitle = (element.value).trim();

					if (todoTitle.length) {
						var newTodoId = todosDB.add(todoTitle);

						context.broadcast('todoadded', {
							id: newTodoId
						});

						// Clear input afterwards
						element.value = '';
					}

					event.preventDefault();
					event.stopPropagation();
				}

			}

		}
function ( event , element , elementType ) { // code to be run when a click occurs if ( elementType === 'new-todo-input' ) { if ( event . keyCode === ENTER_KEY ) { var todoTitle = ( element . value ) . trim ( ) ; if ( todoTitle . length ) { var newTodoId = todosDB . add ( todoTitle ) ; context . broadcast ( 'todoadded' , { id : newTodoId } ) ; // Clear input afterwards element . value = '' ; } event . preventDefault ( ) ; event . stopPropagation ( ) ; } } }
Handles the keydown event for the module.
@param {Event} event A DOM-normalized event object.
@param {HTMLElement} element The nearest HTML element with a data-type
attribute specified or null if there is none.
@param {string} elementType The value of data-type for the nearest
element with that attribute specified or null if there is none.
@returns {void}
Handles the keydown event for the module .