Skip to content

Instantly share code, notes, and snippets.

-var events = _.clone(Backbone.Events);
-
var Status = Backbone.Model.extend({
url: '/status'
});
-var Statuses = function() {
-};
-Statuses.prototype.add = function(text) {
- var status = new Status();
$('form').bind('submit', function() {
alert('User submitted form');
});
$(document).ready(function() {
$('#new-status').submit(function(e) {
e.preventDefault();
$.ajax({
url: '/status',
type: 'POST',
dataType: 'json',
data: { text: $(this).find('textarea').val() },
success: function(data) {
@kimjoar
kimjoar / done.js
Created July 13, 2012 20:37
Done!
var Status = Backbone.Model.extend({
url: '/status'
});
var Statuses = Backbone.Collection.extend({
model: Status
});
var NewStatusView = Backbone.View.extend({
events: {
@kimjoar
kimjoar / 20.diff
Created July 13, 2012 20:21
Step 20 -> 21
var Status = Backbone.Model.extend({
url: '/status'
});
var Statuses = Backbone.Collection.extend({
model: Status
});
var NewStatusView = Backbone.View.extend({
+ events: {
@kimjoar
kimjoar / 19.diff
Created July 13, 2012 20:21
Step 19 -> 20
var Status = Backbone.Model.extend({
url: '/status'
});
var Statuses = Backbone.Collection.extend({
model: Status
});
var NewStatusView = Backbone.View.extend({
- initialize: function(options) {
@kimjoar
kimjoar / 18.diff
Created July 13, 2012 20:21
Step 18 -> 19
var Status = Backbone.Model.extend({
url: '/status'
});
var Statuses = Backbone.Collection.extend({
- add: function(text) {
- var that = this;
- var status = new Status();
- status.save({ text: text }, {
- success: function(model, data) {
@kimjoar
kimjoar / 17.diff
Created July 13, 2012 20:20
Step 17 -> 18
var events = _.clone(Backbone.Events);
+var Status = Backbone.Model.extend({
+ url: '/status'
+});
+
var Statuses = function() {
};
Statuses.prototype.add = function(text) {
- $.ajax({
@kimjoar
kimjoar / 16.diff
Created July 13, 2012 20:20
Step 16 -> 17
var events = _.clone(Backbone.Events);
var Statuses = function() {
};
Statuses.prototype.add = function(text) {
$.ajax({
url: '/status',
type: 'POST',
dataType: 'json',
data: { text: text },
@kimjoar
kimjoar / 15.diff
Created July 13, 2012 20:20
Step 15 -> 16
var events = _.clone(Backbone.Events);
var Statuses = function() {
};
Statuses.prototype.add = function(text) {
$.ajax({
url: '/status',
type: 'POST',
dataType: 'json',
data: { text: text },