Skip to content

Instantly share code, notes, and snippets.

View lacides's full-sized avatar

Lacides Charris lacides

  • Koombea
  • Barranquilla, Colombia
View GitHub Profile
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.
require 'active_resource'
module ActiveResourceCaching
extend ActiveSupport::Concern
included do
class_attribute :cache
self.cache = nil
end
(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"
(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"
},
(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){
window.Anotherchat = {
Models: {},
Collections: {},
Views: {},
Routers: {},
init: function() {
new Anotherchat.Routers.Messages;
Backbone.history.start({root: "/messages/"});
}
};
(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
<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>
(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);
<p>
<strong><%= @message.get 'user_email' %> said:</strong><%= @message.get 'message' %>
</p>