This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I do not aim with my hand; he who aims with his hand has forgotten the face of his father. | |
I aim with my Pip-Boy. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
Anotherchat.Views.MessagesIndex = Backbone.View.extend({ | |
el: '#app', | |
template: JST['messages/index'], | |
initialize: function(){ | |
this.collection.on("reset", this.render, this); | |
this.collection.on("sync", this.render, this); | |
}, | |
events: { | |
"submit #new_message": "new_message" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
Anotherchat.Views.MessagesIndex = Backbone.View.extend({ | |
el: '#app', | |
template: JST['messages/index'], | |
initialize: function(){ | |
this.collection.on("reset", this.render, this); | |
}, | |
events: { | |
"submit #new_message": "new_message" | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
Anotherchat.Views.MessagesIndex = Backbone.View.extend({ | |
el: '#app', | |
template: JST['messages/index'], | |
initialize: function(){ | |
this.collection.on("reset", this.render, this); | |
}, | |
render: function(){ | |
jQuery(this.el).html(this.template); | |
this.collection.each(function(message){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.Anotherchat = { | |
Models: {}, | |
Collections: {}, | |
Views: {}, | |
Routers: {}, | |
init: function() { | |
new Anotherchat.Routers.Messages; | |
Backbone.history.start({root: "/messages/"}); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
Anotherchat.Routers.Messages = Backbone.Router.extend({ | |
routes: { | |
"": "index" | |
}, | |
index: function(){ | |
var messages = new Anotherchat.Collections.Messages; | |
messages.fetch(); | |
var view = new Anotherchat.Views.MessagesIndex({ | |
collection: messages |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="page-header"> | |
<h1>Chat</h2> | |
</div> | |
<div id="chat-area" /> | |
<form id="new_message"> | |
<input id="message" name="message" size="30" type="text"> | |
<input name="commit" type="submit" value="Create Message"> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
Anotherchat.Views.MessagesIndex = Backbone.View.extend({ | |
el: '#app', | |
template: JST['messages/index'], | |
render: function(){ | |
jQuery(this.el).html(this.template); | |
this.collection.each(function(message){ | |
var messageView = new Anotherchat.Views.Message({model: message}); | |
messageView.render(); | |
jQuery("#chat-area").append(messageView.el); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p> | |
<strong><%= @message.get 'user_email' %> said:</strong><%= @message.get 'message' %> | |
</p> |
NewerOlder