- what are the common problems backbone didn’t solve?
- no data binding by default, no two way data binding by default
- How do you render Views? - By default, Backbone's render method does nothing. To use it, you need to fill in your own rendering function. That could use a templating system like Underscore templates or Handlebars, jQuery manipulation of the DOM, or simple string inserts with .innerHTML(). You could use the same method for every View, or mix it up and use different methods for different Views.
- How do you manage relationships between objects? - By default Backbone provides a way to manage sets of Models as a Collection, but it doesn't have any built-in utilities for handling nested Models or Collections. And if you want to nest your Views you're completely on your own. You can have a View manage it's child Views, have a single object that manages all Views, or let each View manage itself.
- How do your Views communicate between each other? - Views will often need to communicate with
This file contains 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
sudo stop admittedly-www | |
# Unset GIT_DIR or the universe will implode | |
unset GIT_DIR | |
# Change directory to the working tree; exit on failure | |
cd `git config --get core.worktree` || exit | |
# Force checkout | |
git checkout --force |
This file contains 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 User < ActiveRecord::Base | |
after_save :some_method, :on => :update | |
after_save :always | |
def some_method | |
puts "i only fire on update" | |
binding.pry | |
end | |
def always |
This file contains 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
big 0 | |
data structures | |
algorithms | |
http://bigocheatsheet.com/ | |
how does Computer memory actually work | |
when we allocate an array in ruby, it decides to use 5 “spaces” of memory | |
draw what this looks like | |
if we use less than this, it’s wasted, but on average we’ve found this is the most efficient | |
when we add the 6th element, we have to copy the whole array and double its size |
This file contains 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
JSON | |
[{ | |
"title": "my products title", | |
"description": "this is a blob of html usually created by a WYSIWYG", | |
"vendor_id": "you can hard code this once we create you in the system", | |
"flavors": [ | |
"chocolate", | |
"orange" | |
], | |
"image": "some url with an image", |
What are the core components of the JSMV* frameworks
- Data Binding between HTML and a client-side JavaScript object model
*backbone has no data binding
- two way(everyone else)
- View Templates
- declarative DOM based (angular) *so here we’re decorating the DOM language itself
- string templating based (underscore, mustache, handlebars)
This file contains 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
def get_a_number(line) | |
if count = line.instance_variable_get("@count") | |
line.instance_variable_set("@count", count += 1) | |
else | |
line.instance_variable_set("@count", 1) | |
count = 1 | |
end | |
line << count | |
count | |
end |
This file contains 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 app = app || {}; | |
$(function() { | |
var myModel = new app.MyModel(); | |
var libraryView = new app.LibraryView(); | |
$( '#someIDinmyindex.html' ).append(libraryView.el); | |
}); |
This file contains 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
- create index.html | |
- order matters | |
- load/require backbone files | |
- load models | |
- load views | |
- load app.js | |
- create an app global variable | |
- in an IIFE instantiate any views you need | |
- views initialize method | |
- should call its render method |
This file contains 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
for (var number in obj) { | |
obj[number].forEach(function(letter) { | |
answer[letter.toLowerCase()] = Number(number) | |
}) | |
} |