Skip to content

Commit 5b56a9e

Browse files
author
Ashwin Hegde
committed
Merge pull request #25 from hegdeashwin/develop
Develop
2 parents d7c3845 + 71aebe7 commit 5b56a9e

File tree

13 files changed

+285
-502
lines changed

13 files changed

+285
-502
lines changed

README.md

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
# Structuring your web apps via Backbone.JS
1+
# Structuring your web apps with Backbone.js
22

3-
This training kit has been developed for those who already have the basic knowledge of JavaScript & jQuery;
4-
As Backbone.JS is entirely written in JavaScript.
3+
This training kit has been developed for those who
4+
* Already have the basic knowledge of JavaScript & jQuery;
5+
* Who wants to write JavaScript in a structured/pattern way;
56

6-
This training kit will teach you the basics of Backbone.JS and introduction to advanced part.
7+
This training kit will teach you the basics of Backbone.js and introduction to advanced part;
78

89
## Prerequisites arranged as per the priority
9-
1010
* JavaScript, jQuery, Underscore.
11-
* Basic understanding of web scripting.
11+
* Basic understanding of web development concepts like functional programming, templating etc.
1212

1313
## Training kit includes below session
14-
* Ch 0 : Getting Started.
15-
* Ch 1 : Backbone Model.
16-
* Ch 2 : Backbone View, Events & Templates.
17-
* Ch 3 : Backbone Collection.
18-
* Ch 4 : Backbone Router.
19-
* Ch 5 : Application DEMO & Plugin examples.
14+
* Ch 1 : Getting Started.
15+
* Ch 2 : Backbone Model.
16+
* Ch 3 : Backbone View, Events & Templates.
17+
* Ch 4 : Backbone Collection.
18+
* Ch 5 : Backbone Router.
19+
* Ch 6 : Application DEMO & Plugin examples.
2020

2121
* For more information on Backbone's coding standards, plugins etc. Please visit <a href="https://github.com/hegdeashwin/Backbone/wiki" target="_blank">Backbone's training kit Github Wiki documentation</a>
2222

@@ -62,53 +62,18 @@ as per the priority.
6262
<dd>An open source enterprise edition of Nebula based upon Backbone + Marionette - A scalable and composite application architecture for Backbone.js. It provides a client-[server]-side stack for building enterprise grade HTML5/Marionette applications. It could be used with any server side like Node.js, Ruby, PHP, JEE, Spring etc. By default it's server side environment comes with Node.js - Loopback (StrongLoop) stack.</dd>
6363
</dl>
6464

65-
66-
## Change Log
67-
68-
<h5>Shows what a particular release does.</h5>
69-
70-
> Release date 2.0.2: from **August 09, 2015**
71-
```
72-
README.MD - Updates.
73-
Examples - Re-factor directory structure.
74-
```
75-
76-
> Release date 2.0.1: from **March 16, 2015**
77-
```
78-
README.MD - Updates.
79-
```
80-
81-
> Release date 2.0.0: from **September 16, 2013** to **October 10, 2014**
82-
```
83-
README.MD - Updates.
84-
Examples - Fixes few examples bugs.
85-
Examples -
86-
6.1 Adds local JSON Google Map API file to use as services.
87-
6.2 Removes _.object to native object way.
88-
Issues - Updates existing issues list.
89-
Wiki - Adds section on "List of useful blogs" on Backbone.
90-
Training Session 5 - Adds callback function to get current route in router example.
91-
JS - Updates backbone.js to version 1.1.0
92-
Training Extended Session -
93-
1.1 Adds plugins example.
94-
1.2 Adds usage & implementation of Backbone-Deep-Model plugin.
95-
```
96-
9765
## Contributors
9866

99-
Developed &amp; maintained by author: <b>Ashwin Hegde</b><br>
67+
Developed & maintained by author: <b>Ashwin Hegde</b>
10068

10169
We really appreciate all kind of feedback and contributions. Thanks for using and supporting this project:
10270
<a href="//github.com/hegdeashwin/Backbone/graphs/contributors" target="_blank">contributors</a>
10371

104-
Visit the following link to know about Backbone current training updates<br>
105-
Home: <a href="https://github.com/hegdeashwin/Backbone#change-log" target="_blank">https://github.com/hegdeashwin/Backbone#change-log</a>
106-
10772
To request a feature or you find any typo errors, enhancements or questions; please feel free to post it on following link, or vote for the ones that are already registered.
10873
<br>Tracking: <a href="https://github.com/hegdeashwin/Backbone/issues" target="_blank">https://github.com/hegdeashwin/Backbone/issues</a>
10974

11075
Visit the following link to know about Backbone's development code in detail.<br>
111-
<strong>Copyright &copy; 2010-2013 Jeremy Ashkenas</strong><br>
76+
<strong>Copyright & 2010-2013 Jeremy Ashkenas</strong><br>
11277
Documentation: <a href="http://documentcloud.github.io/backbone/docs/backbone.html" target="_blank">http://documentcloud.github.io/backbone/docs/backbone.html</a>.
11378

11479
## License

codes/Ch3_View_Events_Templates/README.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@
4141
* Trigger a subscribed event
4242

4343
### Example 4:
44-
*
45-
*
46-
*
47-
48-
### Example 5:
49-
*
50-
*
51-
*
52-
53-
### Example 6:
54-
*
55-
*
56-
*
44+
* New way to Subscribe/Unsubscribe a custom event
45+
* New way to Subscribe a custom event onces
46+
* Trigger a subscribed event

codes/Ch4_Collection/Examples/Example1/Example-1.html

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,14 @@
33
<head>
44
<meta charset="utf-8">
55
<title>Example 1: Backbone Collection</title>
6-
<style>
7-
body { padding-top: 20px; }
8-
</style>
9-
<link href="../../../css/bootstrap.min.css" rel="stylesheet"/>
106
</head>
117
<body>
12-
<div class="container">
13-
<div class="row">
14-
<div class="hero-unit">
15-
<div class="row">
16-
<h2>Structuring your web apps via Backbone.JS</h2>
17-
</div>
18-
<div class="row">
19-
<h3>Ch 3: Understanding Backbone Collection</h3>
20-
</div>
21-
<hr>
22-
<p class="lead">How to run this example.</p>
23-
<ol>
24-
<li>Open Example-1.html in browser.</li>
25-
<li>Press F12, go to console tab.</li>
26-
<li>See the message get displayed on that console tab.</li>
27-
</ol>
28-
</div>
29-
</div>
30-
</div>
8+
<h1>Ch 4: Understanding Backbone Collection</h1>
9+
<h2>How to run this example?</h2>
10+
<ol>
11+
<li>Open Example-1.html in browser.</li>
12+
<li>Press F12, go to console tab.</li>
13+
</ol>
3114

3215
<!-- Step 1:
3316
Include jQuery, Here the jQuery is included with in js directory,
@@ -49,21 +32,12 @@ <h3>Ch 3: Understanding Backbone Collection</h3>
4932
<script src="../../../js/underscore-min.js" type="text/javascript"></script>
5033

5134
<!-- Step 3:
52-
Include JSON2, Here the JSON2 is included with in js directory,
53-
Thus the relative path for the file becomes ../../../js/json2.js
54-
55-
IMPORTANT NOTE:
56-
json2.js should always included for JSON support for older browsers.
57-
-->
58-
<script src="../../../js/json2.js" type="text/javascript"></script>
59-
60-
<!-- Step 4:
6135
Include Backbone, Here the Backbone is included with in js directory,
6236
Thus the relative path for the file becomes ../../../js/backbone.js
6337
-->
6438
<script src="../../../js/backbone-min.js" type="text/javascript"></script>
6539

66-
<!-- Step 5:
40+
<!-- Step 4:
6741
Include example-main-1.js, Here the example-main-1.js is included with in js directory,
6842
Thus the relative path for the file becomes example-main-1.js.
6943

codes/Ch4_Collection/Examples/Example1/example-main-1.js

Lines changed: 85 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,135 @@
11
(function() {
2-
/*
3-
The goal of this file is to provide the basic understanding
4-
1. Create a Collection class.
5-
2. Passing Model to Collection.
6-
3. Setting build-in Collection events.
7-
4. Get Model using at-index.
8-
5. Remove Model from the Collection.
9-
6. Get the length of Collection.
10-
7. Add Model into the Collection at the end.
11-
8. Remove Model from the Collection from the end.
12-
9. Add Model into the Collection at the start.
13-
10. Remove Model from the Collection from the start.
14-
11. Getting data in object & string format.
15-
16-
17-
How to run this example.
18-
1. Open Example-1.html in Google Chrome browser.
19-
2. Press F12, go to console tab.
20-
3. See the message get displayed on that console tab.
21-
*/
2+
/**
3+
* The goal of this file is to provide the basic understanding of
4+
* 1. Create a Collection
5+
* 2. Passing Model to Collection
6+
* 3. Setting build-in Collection events
7+
* 4. Add/Remove Model from collection at the end
8+
* 5. Add/Remove Model from collection at the start
9+
* 6. Get the length of collection
10+
*/
2211

2312
var MasterModel = Backbone.Model.extend({
24-
/*
25-
This initialize function will get called when the model is first created.
26-
*/
13+
/**
14+
* `initialize` is a constructor function which gets called automatically at
15+
* the time of instance creation
16+
*/
2717
initialize: function() {
2818
console.log("Your model have been initialize");
2919
}
3020
});
3121

32-
/*
33-
Creating a new collection called MasterCollection by extending Backbone.Collection class.
34-
Syntax: Backbone.Collection.extend(properties, [classProperties])
35-
*/
3622
var MasterCollection = Backbone.Collection.extend({
37-
/*
38-
This initialize function will get called when the collection is first created.
39-
*/
4023
initialize: function() {
4124
console.log("Your collection have been initialize.");
25+
26+
/**
27+
* Subscribe collection events
28+
*/
4229
this.listenTo(this, 'add', this.onModelAdded);
43-
this.listenTo(this, 'remove', this.onModelRemoved);
30+
this.listenTo(this, 'remove', this.onModelRemoved);
4431
},
4532

46-
/*
47-
Used to specify the model class that the collection contains.
48-
*/
33+
/**
34+
* Used to specify the model class that the collection contains.
35+
*/
4936
model: MasterModel,
5037

5138
onModelAdded: function() {
52-
console.log("[Add model event got fired]");
39+
console.log("Add model event got fired");
5340
},
5441

5542
onModelRemoved: function() {
56-
console.log("[Remove model event got fired]");
43+
console.log("Remove model event got fired");
5744
}
5845
});
5946

60-
/*
61-
Creating an object from MasterCollection which calls initialize function.
62-
*/
6347
var masterCollection = new MasterCollection();
6448

65-
/*
66-
Add a model (or an array of models) to the collection.
67-
Firing an "add" event.
68-
*/
69-
masterCollection.add(new MasterModel({name: 'Ashwin Hegde'}));
70-
masterCollection.add(new MasterModel({name: 'Vinayak Patil'}));
71-
masterCollection.add(new MasterModel({name: 'Jerin John'}));
72-
73-
/*
74-
Display the data currently added in the collection.
75-
*/
49+
/**
50+
* Add a model (or an array of models) to the collection.
51+
* Firing an "add" event.
52+
*/
53+
masterCollection.add(new MasterModel({
54+
name: 'Ashwin Hegde'
55+
}));
56+
masterCollection.add(new MasterModel({
57+
name: 'Vinayak Patil'
58+
}));
59+
masterCollection.add(new MasterModel({
60+
name: 'Pavan Solanki'
61+
}));
62+
63+
/**
64+
* Display the data currently added in the collection.
65+
*/
7666
console.log("Data in Collection :: Add ")
7767
console.log(masterCollection.toJSON());
7868

79-
/*
80-
Remove a model (or an array of models) from the collection. Fires a "remove" event,
81-
82-
`at` is used to get a model from a collection, specified by index.
83-
Note: index starts from 0
84-
*/
69+
/**
70+
* Remove a model (or an array of models) from the collection. Fires a "remove" event,
71+
*
72+
* `at` is used to get a model from a collection, specified by index.
73+
* Note: index starts from 0
74+
*/
8575
masterCollection.remove(masterCollection.at(1));
86-
/*
87-
Display the data after removing model from the collection.
88-
*/
76+
77+
/**
78+
* Display the data after removing model from the collection.
79+
*/
8980
console.log("Remove data from Collection :: Remove ")
9081
console.log(masterCollection.toJSON());
9182

92-
/*
93-
Collection maintains a length property, counting the number of models it contains.
94-
*/
83+
/**
84+
* Collection maintains a length property, counting the number of models it contains.
85+
*/
9586
console.log("Collection length: " + masterCollection.length);
9687

88+
/**
89+
* Add a model at the end of a collection.
90+
*/
91+
masterCollection.push(new MasterModel({
92+
name: 'Kumar Kundan'
93+
}));
9794

98-
/*
99-
Add a model at the end of a collection.
100-
*/
101-
masterCollection.push(new MasterModel({name: 'Saju Sasidharan'}));
102-
/*
103-
Display the data currently added in the collection.
104-
*/
95+
/**
96+
* Display the data currently added in the collection.
97+
*/
10598
console.log("Data in Collection :: Push");
10699
console.log(masterCollection.toJSON());
107100

108-
/*
109-
Remove and return the last model from a collection
110-
*/
101+
/**
102+
* Remove and return the last model from a collection
103+
*/
111104
masterCollection.pop();
112-
/*
113-
Display the data after removing last model from the collection.
114-
*/
105+
106+
/**
107+
* Display the data after removing last model from the collection.
108+
*/
115109
console.log("Data in Collection :: POP");
116110
console.log(masterCollection.toJSON());
117111

112+
/**
113+
* Add a model at the beginning of a collection.
114+
*/
115+
masterCollection.unshift(new MasterModel({
116+
name: 'Ajay Sajwan'
117+
}));
118118

119-
/*
120-
Add a model at the beginning of a collection.
121-
*/
122-
masterCollection.unshift(new MasterModel({name: 'Yogesh Gaikwad'}));
123-
/*
124-
Display the data currently added in the collection.
125-
*/
119+
/**
120+
* Display the data currently added in the collection.
121+
*/
126122
console.log("Data in Collection :: unshift");
127123
console.log(masterCollection.toJSON());
128124

129-
/*
130-
Remove and return the first model from a collection.
131-
*/
125+
/**
126+
* Remove and return the first model from a collection.
127+
*/
132128
masterCollection.shift();
133-
/*
134-
Display the data after removing first model from the collection.
135-
*/
129+
130+
/**
131+
* Display the data after removing first model from the collection.
132+
*/
136133
console.log("Data in Collection :: Shift");
137134
console.log(masterCollection.toJSON());
138135

0 commit comments

Comments
 (0)