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.Message = Backbone.View.extend({ | |
tagName: 'div', | |
template: JST["messages/message"], | |
render: function(){ | |
$(this.el).html(this.template({message: this.model})); | |
return this; | |
} | |
}); | |
})(jQuery); |
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.Collections.Messages = Backbone.Collection.extend({ | |
url: '/messages' | |
}); | |
})(jQuery); |
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.Models.Message = Backbone.Model.extend({}); | |
})(jQuery); |
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() { | |
alert('Hello from Backbone!'); | |
} | |
}; |
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
source 'https://rubygems.org' | |
gem 'rails', '3.2.3' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
gem 'pg' | |
gem 'devise' |
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
<html> | |
<head> | |
<title>Backbone.js and Server Sent Events</title> | |
<meta charset="utf-8" /> | |
<script src="/javascripts/jquery.min.js"></script> | |
<script src="/javascripts/bootstrap.min.js"></script> | |
<script src="/javascripts/navigation.js"></script> | |
<link rel="stylesheet" href="/stylesheets/bootstrap.min.css"> | |
<link rel="stylesheet" href="/stylesheets/bootstrap-responsive.min.css"> |
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
var messages = Backbone.Collection.extend({ | |
model: message, | |
url: '/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
var message = Backbone.Model.extend({}); |
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 id="app"> | |
</div> |
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
class MessagesController < ApplicationController | |
before_filter :authenticate_user! | |
def index | |
@messages = Message.all | |
respond_to do |format| | |
format.html | |
format.json { render json: @messages } | |
end | |
end |