summaryrefslogtreecommitdiffstats
path: root/_posts
diff options
context:
space:
mode:
authorRyan Kirkman <ryan@ryankirkman.com>2011-10-11 20:18:20 +1000
committerRyan Kirkman <ryan@ryankirkman.com>2011-10-11 20:18:20 +1000
commitae82f62d68e9b9e2ef6a82989863fed07a2e06c1 (patch)
tree0b70630a4a743cf873e72a98070c98919c33ed92 /_posts
parent83690fdac5aca5e924079afd91ae06bd8351f6ea (diff)
downloadbackbonetutorials-ae82f62d68e9b9e2ef6a82989863fed07a2e06c1.zip
backbonetutorials-ae82f62d68e9b9e2ef6a82989863fed07a2e06c1.tar.gz
backbonetutorials-ae82f62d68e9b9e2ef6a82989863fed07a2e06c1.tar.bz2
Fuck
Diffstat (limited to '_posts')
-rw-r--r--_posts/2011-01-26-what-is-a-collection.textile9
-rw-r--r--_posts/2011-10-10-organizing-backbone-using-modules.textile101
2 files changed, 103 insertions, 7 deletions
diff --git a/_posts/2011-01-26-what-is-a-collection.textile b/_posts/2011-01-26-what-is-a-collection.textile
index 6fdaca5..33e6264 100644
--- a/_posts/2011-01-26-what-is-a-collection.textile
+++ b/_posts/2011-01-26-what-is-a-collection.textile
@@ -66,14 +66,9 @@ p. Now we are going to populate a creation with some useful data.
{% endhighlight %}
-h3. So how does Backbone.js help?
-
-p. Backbone is an incredibly small library for the amount of functionality and structure it gives you. One can not easily summarize the benefits you will reap from using it. If you read through some of the beginner tutorials the benefits will soon become self evident and due to Backbone.js light nature you can incrementally include it in any current or future projects.
-
-
h3. Relevant Links
* "Backbone.js official website":http://documentcloud.github.com/backbone/
-* "great hackernews discussion /w post from author":http://news.ycombinator.com/item?id=2119704
+
h3. Author
@@ -82,4 +77,4 @@ h3. Author
h3. Contributors
-* "FND":https://github.com/FND
+* None
diff --git a/_posts/2011-10-10-organizing-backbone-using-modules.textile b/_posts/2011-10-10-organizing-backbone-using-modules.textile
new file mode 100644
index 0000000..5cbb323
--- /dev/null
+++ b/_posts/2011-10-10-organizing-backbone-using-modules.textile
@@ -0,0 +1,101 @@
+---
+layout: post
+title: Organizing your application using Modules (require.js)
+type: intermediate
+posturl: http://backbonetutorials.com/organizing-backbone-using-modules
+---
+
+h2. Organizing your application using Modules (require.js)
+
+p. Unfortunatly Backbone.js does not tell you how to organize your code leaving many developers in the dark of how to load scripts and lay out their development enviroments.
+
+This was quite a different decision to other Javascript MVC frameworks who were more in favor of setting a development philosophy.
+
+This tutorial will get you started on combining Backbone.js with "AMD":http://www.com (Asynchronous Module Definitions).
+
+h3. What is AMD?
+
+p. "Asynchronous Module Definitions":http:www.com designed to load modular code asynchronously in the browser and server. It is actually a fork of the Common.js specification. Many script loaders have built their implementations around AMD, seeing it as the future of modular Javascript development.
+
+This tutorial will use "Require.js":http://requirejs.org to implement a modular and organized Backbone.js.
+
+**I highly recommend using AMD for application development**
+
+Quick Overview
+* Modular
+* Scalable
+
+h3. Why Require.js?
+
+p. Require.js has a great community.
+
+h3. Getting started
+
+
+* Model: Student, Collection: ClassStudents
+* Model: Todo Item, Collection: Todo List
+* Model: Animals, Collection: Zoo
+
+Typically your collection will only use one type of model but models themselves are not limited to a type of collection;
+
+* Model: Student, Collection: Gym Class
+* Model: Student, Collection: Art Class
+* Model: Student, Collection: English Class
+
+Here is a generic Model/Collection example.
+
+{% highlight javascript %}
+
+ var Song = Backbone.Model.extend({
+ initialize: function(){
+ console.log("Music is the answer");
+ }
+ });
+
+ var Album = Backbone.Collection.extend({
+ model: Song
+ });
+
+{% endhighlight %}
+
+h3. Building a collection
+
+p. Now we are going to populate a creation with some useful data.
+
+{% highlight javascript %}
+
+ var Song = Backbone.Model.extend({
+ defaults: {
+ name: "Not specified",
+ artist: "Not specified"
+ },
+ initialize: function(){
+ console.log("Music is the answer");
+ }
+ });
+
+ var Album = Backbone.Collection.extend({
+ model: Song
+ });
+
+ var song1 = new Song({ name: "How Bizarre", artist: "OMC" });
+ var song2 = new Song({ name: "Sexual Healing", artist: "Marvin Gaye" });
+ var song3 = new Song({ name: "Talk It Over In Bed", artist: "OMC" });
+
+ var myAlbum = new Album([ song1, song2, song3]);
+ console.log( myAlbum.models ); // [song1, song2, song3]
+
+{% endhighlight %}
+
+h3. Relevant Links
+* "Backbone.js official website":http://documentcloud.github.com/backbone/
+
+
+
+h3. Author
+
+* "Thomas Davis":https://github.com/thomasdavis
+
+h3. Contributors
+
+* None