Skip to content

Instantly share code, notes, and snippets.

@nkbt
Created December 23, 2013 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nkbt/8095927 to your computer and use it in GitHub Desktop.
Save nkbt/8095927 to your computer and use it in GitHub Desktop.
define('app/chat', [
'dom', 'underscore', 'lib/app'
], function ($, _, app) {
"use strict";
function init() {
var $element = $('.jsAppChat').html(app.template('template/app/chat'));
$element.find('.jsAppChat-formContainer')
.html(app.template('template/app/chat/form'));
}
function onSubmit(event) {
event.preventDefault();
var $form = $(event.target).closest('.jsAppChat-form'),
$input = $form.find('input[name=text]');
$input.trigger('app/chat:addMessage', [$input.val()]);
}
app.$root
.on('submit', '.jsAppChat .jsAppChat-form', onSubmit);
$(init);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment