Skip to content

Instantly share code, notes, and snippets.

@rightson
rightson / backbone1-env.html
Created June 24, 2012 23:12
Backbone JS Environment Setup
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title> Learning about Bacjbone.js </title>
</head>
<body>
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone-min.js"></script>
<script type="text/javascript">
Person = Backbone.Model.extend({
initialize: function() {
console.log('hello world!');
}
});
var person = new Person({ name: "Joe", height: "6 feet" });
Person = Backbone.Model.extend({
initialize: function() {
console.log("hello world!");
},
defaults: {
name: "Scott",
height: "unknown"
}
});
Person = Backbone.Model.extend({
initialize: function() {
console.log("hello world!");
this.bind("change:name", function() {
console.log(person.get('name'));
});
}
//...
});
Person = Backbone.Model.extend({
initialize: function() {
console.log('hello world!');
this.bind("change:name", function() {
console.log(persion.get('name'));
});
this.bind("error", function(model, error) {
console.log('error');
});
},
var person = new Person();
console.log(person.get('name'));
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title> Learning about Bacjbone.js </title>
</head>
<body>
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone-min.js"></script>
<script type="text/javascript">
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Learning About Backbone.js AJAX</title>
</head>
<body>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<?php
try {
$content = array();
$con = mysql_connect('localhost', 'test', '');
mysql_select_db('backbone', $con);
mysql_query("INSERT INTO log SET date=NOW(), content='GET=".json_encode($_GET)."\nPOST=".json_encode($_POST)."';");
/** READ **/