GithubHelp home page GithubHelp logo

antoviaque / backbone-relational-tutorial Goto Github PK

View Code? Open in Web Editor NEW
75.0 6.0 22.0 1.38 MB

Backbone-relational Tutorial - Nested Models With Backbone.js

Home Page: http://antoviaque.org/

License: Other

Shell 0.07% JavaScript 80.82% CSS 3.32% HTML 15.78%

backbone-relational-tutorial's Introduction

Backbone-relational Tutorial - Nested Models With Backbone.js

Introduction

Backbone.js

Backbone.js allows to implement the whole MVC pattern on the client, leaving the server to do what he knows best: exposing a set of well-defined REST interfaces, which the client queries when he needs to fetch or update some information. No need to split the HTML rendering between the server templates and the client-side javascript.

It's not only cleaner, it's also an excellent architecture to make responsive applications. Less information needs to be exchanged with the server - the formatting (views and controllers) being on the client, you only need to exchange the data being manipulated on the REST interfaces.

No full page reload - the server sends a static HTML file upon the first request, then the JS client handles the interaction with the user, only remodeling the portions of the DOM that changes between pages. And, better still, Backbone.js takes care of a large part of the work required to synchronize data with the server. Sweet!

Backbone-relational

However, when I recently started to learn about Backbone, I realized it doesn't help to handle relationships between models. Most non-trivial applications need this - forum threads each have a series of comments, billing invoices have several items to charge for...

If you're reading this, you've probably found out about backbone-relational after reading a few threads. But the documentation is sparse, and it's hard to see how to use it practically. How do you structure your views to represent the relations between models? How do you update or push relational models to their corresponding REST APIs?

Read the full tutorial - Backbone-relational, Nested Models With Backbone.js

backbone-relational-tutorial's People

Contributors

antoviaque avatar brendannee avatar joenyland avatar sanperrier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

backbone-relational-tutorial's Issues

App doesn't start

backbone-relational-tutorial]$ node app

/Users/jleppert/devel/backbone-relational-tutorial/node_modules/mongoose/lib/schema.js:276
throw new TypeError('Invalid value for schema Array path '+ prefix + ke ^ TypeError: Invalid value for schema Array pathmessages`
at Schema.add (/Users/jleppert/devel/backbone-relational-tutorial/node_modules/mongoose/lib/schema.js:276:13)
at new Schema (/Users/jleppert/devel/backbone-relational-tutorial/node_modules/mongoose/lib/schema.js:87:10)
at Object. (/Users/jleppert/devel/backbone-relational-tutorial/models.js:13:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/Users/jleppert/devel/backbone-relational-tutorial/app.js:33:14)

Typo

Hi,

I think you have a typo in the REST API - GET /api/thread/:id section. In the last paragraph you talk about Django-relational when it should be Backbone-relational, shouldn't it?

Add documentation concerning node.js & package versions

Thanks for the tutorial, useful for making a facebook messages-like UI

Trying the server app with the latest version of node (0.10.5) results in a "Not Found" http response.
So I switched to the Node.js 0.6.12, but the package.json tells to grab the latest version of the packages which result in errors. I solved by removing the "at least" directives, everything works as expected now.

Since I'm new to Node.js, I had to scratch my head a little bit, could you add notes about this problem ?

Cannot find module 'domain' when starting node.js

Hi there,

I tried following your tutorial guide in using backbone js with nested relational tutorial. I followed all the installation ie node.js, mongodb install till I start node js up.

And this is the error message I received when starting up...

andy@LINUXAWCM:~/Projects/Javascript/backbone-relational-tutorial$ node app
js-bson: Failed to load c++ bson extension, using pure JS version

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'domain'
at Function._resolveFilename (module.js:332:11)
at Function._load (module.js:279:25)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object. (/home/andy/Projects/Javascript/backbone-relational-tutorial/node_modules/restify/lib/server.js:3:14)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)

Says that it complains module 'domain' is not found. So I ran this command

andy@LINUXAWCM:~/Projects/Javascript/backbone-relational-tutorial$ sudo npm install domain -g
[sudo] password for andy:
npm http GET http://registry.npmjs.org/domain
npm http 304 http://registry.npmjs.org/domain
npm ERR! error rolling back Error: UNKNOWN, unknown error '/usr/local/lib/node_modules/domain'
npm ERR! error rolling back [email protected] { [Error: UNKNOWN, unknown error '/usr/local/lib/node_modules/domain']
npm ERR! error rolling back errno: -1,
npm ERR! error rolling back code: 'UNKNOWN',
npm ERR! error rolling back path: '/usr/local/lib/node_modules/domain' }
npm ERR! Error: UNKNOWN, unknown error '/usr/local/lib/node_modules/domain'
npm ERR! If you need help, you may report this entire log,
npm ERR! including the npm and node versions, at:
npm ERR! http://github.com/isaacs/npm/issues

npm ERR! System Linux 3.5.0-49-generic
npm ERR! command "node" "/usr/local/bin/npm" "install" "domain" "-g"
npm ERR! cwd /home/andy/Projects/Javascript/backbone-relational-tutorial
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.3.26
npm ERR! path /usr/local/lib/node_modules/domain
npm ERR! code UNKNOWN
npm ERR! errno -1
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/andy/Projects/Javascript/backbone-relational-tutorial/npm-debug.log
npm ERR! not ok code undefined
npm ERR! not ok code -1

It suggested the module domain cannot be downloaded from registry.npmjs.org, thus I'm confused how does one need to be able to get app up and running if the module required does not exist?

Hope you can help me out on this.

Thanks,

Andy

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.