Giter Site home page Giter Site logo

grumblr_backbone's Introduction

Grumblr Backbone

Part One

You've had a chance to define models and collections for grumbles in class. For homework, we'd like you to set up both models and collections for comments on a grumble.

Getting Started Tips

  1. Define a model for a comment using Backbone.Model.extend
  • You know it worked if:
    • You can create a new comment in the console using
    • var comment = new App.Models.Comment({authorName: "bob", content: "learned backbone today!!"})
  1. Define a comments collection using Backbone.Collection.extend
  • You know it worked if:
    • You can instantiate a comments collection
    • var comments = new App.Collections.Comments([comment1, comment2, comment3])
  1. Associate comments with models

Associations in backbone are a little tricky, but we can associate two collections by modifying the Grumble model using this and an initialize method:

// js/models/grumble.js
App.Models.Grumble = Backbone.Model.extend({
  urlRoot: "http://grumblr.wdidc.org/grumbles",
  initialize: function(){
    this.comments = new Comments();
    this.comments.url = this.url() + "/comments";
  }
});

Bonus

Try CRUD'ing a few comments using the developer console and the public grumblr api: http://grumblr.wdidc.org/grumbles


grumblr_backbone's People

Contributors

jshawl avatar

Watchers

James Cloos avatar Sean Tay avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.