https://github.com/aodin/backpain
Tutorials and Design Patterns for Backbone.js
https://github.com/aodin/backpain
Last synced: 2 months ago
JSON representation
Tutorials and Design Patterns for Backbone.js
- Host: GitHub
- URL: https://github.com/aodin/backpain
- Owner: aodin
- Created: 2013-02-08T23:57:07.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-04-15T23:06:20.000Z (about 12 years ago)
- Last Synced: 2025-01-21T08:30:04.485Z (4 months ago)
- Language: JavaScript
- Size: 296 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Backpain
========Tutorials and Design Patterns for Backbone.js
### Hidden Operations:
* The `initialize` function and its parameters
* Caching of `$el` parameter
* The `url` versus `urlRoot` of `Model` and `url` of `Collection`
* Extending `url` and `parse` functions for your server-side setup
* Operations that are `silent` by default
* Promotion of certain `options` to the root `this`
* DOM elements can be jQuery selectors or the jQuery object itself
* The `this.$()` shortcut for `this.$el.find()`### Syntax Reminders
* End every attribute with a comma
* Ending `render` functions with return this;`### Design Patterns
* Separation of `Collection` render methods: `render` and `renderItem`
* Underscore templates, especially caching templates
* Returning an object from `Model.validate`### Gotchas
* Memory leaks / duplicate events when binding to views
* Bootstraping data does not fire events
* Overwriting the `el` element in views
* Forgetting the `new` operator
* The View `setElement` will create a new `$el` object and replace `tagName`