Skip to content

Instantly share code, notes, and snippets.

@jmoyers
Created May 9, 2011 03:36
Show Gist options
  • Save jmoyers/962014 to your computer and use it in GitHub Desktop.
Save jmoyers/962014 to your computer and use it in GitHub Desktop.
var chat = new Controller({
view : $('#chat-content'),
socket: app.socket,
model : chatCollection
});
chat.on('model.add', function(event){
this.socket.send({
type : 'chat',
data : event)
});
})
chat.on('view.keypress', function(event, element){
if (event.keyCode == KEYS.enter) {
this.model.push(new Chat({
message : element.val(),
from : me._id,
time : new Date()
}));
element.val('').blur();
setTimeout(function(){
element.focus();
},0);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment