Source: views/layout/header/header.js

var Marionette = require('backbone.marionette');

var tpl = require('./header.hbs');

/**
 * @version 1.0.0
 * @description Header View
 * @module views/layout/header/header
 * @link {http://marionettejs.com/}
 */
module.exports = Marionette.ItemView.extend({

    /** template */
    template: tpl,

    /**
     * @desc UI bindings create cached attributes that
     * point to jQuery selected objects
     */
    ui: {
        input: '#new-todo'
    },

    /** events */
    events: {
        'submit form': 'onSubmit'
    },

    /**
     * @desc onSubmit event handler
     * @func onSubmit
     * @param e
     */
    onSubmit: function (e) {
        // prevent form original submit
        e.preventDefault();

        var todoText = this.ui.input.val().trim();
        if (todoText) {
            this.collection.create({
                title: todoText
            });
            this.ui.input.val('');
        }
    }

});
DocStrap Copyright © 2012-2014 The contributors to the JSDoc3 and DocStrap projects.
Documentation generated by JSDoc 3.2.2 on Mon May 18th 2015 using the DocStrap template.