GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — rename projects · xescodes/fullstack-javascript@07fab3f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • chapter5
    • chapter5.md
    • media
      • board-1.png
  • chapter6
    • chapter6.md
  • code
    • 05-board-backbone-parse-sdk
      • .gitignore
      • README.md
      • app.js
      • css
        • bootstrap.css.map
        • bootstrap.css
        • bootstrap.min.css.map
        • bootstrap.min.css
        • style.css
      • footer.html
      • header.html
      • home.html
      • index.html
      • index.php
      • js
        • backbone.js
        • jquery.js
        • parse-1.5.0.js
        • underscore.js
      • libs
        • require.js
        • require.min.js
        • text.js
    • 06-hello
      • Procfile
      • package.json
      • server.js
    • 06-test
      • Procfile
      • mb-server.js
      • package.json
      • test.js
    • libraries
      • package
        • build
          • parse-latest.js
        • package.json
      • parse-1.5.0.tgz
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎chapter5/chapter5.md‎

Copy file name to clipboardExpand all lines: chapter5/chapter5.md
+36-30Lines changed: 36 additions & 30 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
<span id="backbone.js-and-parse.com" class="anchor"></span>
1+
<span id="backbone.js-and-Parse" class="anchor"></span>
22
CHAPTER 5
33
---------
4-
Backbone.js and Parse.com
4+
Backbone.js and Parse
55
=========================
66
> *Java is to JavaScript what Car is to Carpet.*
77
>
88
> — [Chris Heilmann](http://christianheilmann.com/)
99
1010
In this chapter, we'll explore the practical aspect of leveraging
11-
Parse.com for a Backbone.js app. The chapter will illustrate the
12-
Backbone.js uses with Parse.com and its JavaScript SDK on the modified
11+
Parse for a Backbone.js app. The chapter will illustrate the
12+
Backbone.js uses with Parse and its JavaScript SDK on the modified
1313
Message Board app.
1414

1515
If you've written some complex client-side applications, you might have
@@ -21,7 +21,7 @@ event listeners, and triggers. For more information and step-by-step
2121
examples of building Backbone.js applications from scratch, please refer
2222
to the chapter "Intro to Backbone.js."
2323

24-
Message Board with Parse.com: JavaScript SDK and Backbone.js Version
24+
Message Board with Parse: JavaScript SDK and Backbone.js Version
2525
====================================================================
2626

2727
<span id="OLE_LINK27" class="anchor"><span id="OLE_LINK26"
@@ -38,9 +38,15 @@ not there were changes to the data. The Backbone.js
3838
Model-View-Controller (MVC) framework can be used to make complex
3939
applications more manageable and easier to maintain.
4040

41+
![alt](media/board-1.png)
42+
43+
***Figure 5-1.** Message Board powered by local Parse server.*
44+
45+
46+
4147
If you felt comfortable with the previous example, let's build upon it
4248
with the use of the Backbone.js framework. Here we'll go step by step,
43-
creating a Message Board application using Backbone.js and Parse.com
49+
creating a Message Board application using Backbone.js and Parse
4450
JavaScript SDK. If you feel familiar enough with it, you could download
4551
the Super Simple Backbone Starter Kit at
4652
[github.com/azat-co/super-simple-backbone-starter-kit](http://github.com/azat-co/super-simple-backbone-starter-kit).
@@ -53,7 +59,7 @@ The application is available at
5359
but again you are encouraged to start from scratch and try to write your
5460
own code using the example only as a reference.
5561

56-
The following shows the structure of Message Board with Parse.com,
62+
The following shows the structure of Message Board with Parse,
5763
JavaScript SDK, and Backbone.js version:
5864

5965
/06-board-backbone-parse-sdk
@@ -110,11 +116,11 @@ Do the same for Underscore v1.8.3 and Backbone v1.2.3:
110116
<script src="js/underscore.js"></script>
111117
<script src="js/backbone.js"></script>
112118

113-
The Parse JavaScript SDK v1.5.0 is hot-linked from Parse.com CDN. Note
114-
the version number, because the older versions might not work properly
119+
The Parse JavaScript SDK v1.5.0 is patched meaning its modifide to work with the local Parse serve. In this version, I commented or delete the `/1` in the URL path. The file is in the js folder of this project. Note
120+
this, because other versions might not work properly
115121
with this example:
116122

117-
<script src="//www.parsecdn.com/js/parse-1.5.0.min.js"></script>
123+
<script src="js/parse-1.5.0.js"></script>
118124

119125
Twitter Bootstrap CSS inclusion:
120126

@@ -175,7 +181,7 @@ We use Require.js syntax and shim plugin for HTML templates:
175181

176182
The application router with a single index route:
177183

178-
var ApplicationRouter = Backbone.Router.extend({
184+
const ApplicationRouter = Backbone.Router.extend({
179185
routes: {
180186
"": "home",
181187
"*actions": "home"
@@ -254,7 +260,7 @@ The full code of the `app.js` file:
254260
headerTpl,
255261
homeTpl,
256262
footerTpl) {
257-
var ApplicationRouter = Backbone.Router.extend({
263+
const ApplicationRouter = Backbone.Router.extend({
258264
routes: {
259265
'': 'home',
260266
'*actions': 'home'
@@ -451,23 +457,23 @@ For your convenience, here's the full code of the `home.html` template file:
451457

452458
Now we can add the following components to:
453459

454-
- Parse.com collection
460+
- Parse collection
455461

456-
- Parse.com model
462+
- Parse model
457463

458464
- Send/add message event
459465

460466
- Getting/displaying messages functions
461467

462-
Backbone-compatible model object/class from Parse.com JS SDK with a
468+
Backbone-compatible model object/class from Parse JS SDK with a
463469
mandatory `className` attribute (this is the name of the collection that
464-
will appear in the Data Browser of the Parse.com web interface):
470+
will appear in the Data Browser of the Parse web interface):
465471

466472
Message = Parse.Object.extend({
467473
className: 'MessageBoard'
468474
})
469475

470-
Backbone-compatible collection object from Parse.com JavaScript SDK that
476+
Backbone-compatible collection object from Parse JavaScript SDK that
471477
points to the model:
472478

473479
MessageBoard = Parse.Collection.extend ({
@@ -512,13 +518,13 @@ Firstly, we get the form object by its ID (`#new-message`) because it's
512518
more effective and readable to use a stored object rather than use
513519
jQuery selector every time.
514520

515-
var newMessageForm = $('#new-message')
521+
const newMessageForm = $('#new-message')
516522

517523
The next two lines will get the values of the input fields with names
518524
`username` and `message`:
519525

520-
var username = newMessageForm.find('[name="username"]').val()
521-
var message = newMessageForm.find('[name="message"]').val()
526+
const username = newMessageForm.find('[name="username"]').val()
527+
const message = newMessageForm.find('[name="message"]').val()
522528

523529
Once we have the values of a new message (text and author), we can
524530
invoke the `this.collection.add`:
@@ -549,7 +555,7 @@ something like this:
549555
550556
Parse.initialize('your-parse-app-id', 'your-parse-js-sdk-key')
551557

552-
var ApplicationRouter = Backbone.Router.extend({
558+
const ApplicationRouter = Backbone.Router.extend({
553559
routes: {
554560
'': 'home',
555561
'*actions': 'home'
@@ -615,9 +621,9 @@ something like this:
615621
})
616622
},
617623
saveMessage: function(){
618-
var newMessageForm = $('#new-message')
619-
var username = newMessageForm.find('[name="username"]').val()
620-
var message = newMessageForm.find('[name="message"]').val()
624+
const newMessageForm = $('#new-message')
625+
const username = newMessageForm.find('[name="username"]').val()
626+
const message = newMessageForm.find('[name="message"]').val()
621627
this.collection.add({
622628
'username': username,
623629
'message': message
@@ -628,11 +634,11 @@ something like this:
628634
}
629635
})
630636

631-
app = new ApplicationRouter ()
637+
window.app = new ApplicationRouter ()
632638
Backbone.history.start()
633639
})
634640

635-
The full source code of the Backbone.js and Parse.com Message Board
641+
The full source code of the Backbone.js and Parse Message Board
636642
application is available at
637643
<https://github.com/azat-co/fullstack-javascript/tree/master/code/06-board-backbone-parse-sdk>.
638644

@@ -642,7 +648,7 @@ Taking Message Board Further
642648
Once you are comfortable that your front-end application works well
643649
locally, with or without a local HTTP server like MAMP or XAMPP, deploy
644650
it to Windows Azure or Heroku. In-depth deployment instructions are
645-
described in the "jQuery and Parse.com" chapter.
651+
described in the "jQuery and Parse" chapter.
646652

647653
In the last two examples, Message Board had very basic functionality.
648654
You could enhance the application by adding more features.
@@ -667,7 +673,7 @@ Additional features for **advanced** level developers:
667673

668674
- Prevent the same user from voting multiple times.
669675

670-
- Add user sign-up and log-in actions by using Parse.com functions.
676+
- Add user sign-up and log-in actions by using Parse functions.
671677

672678
- Add a *Delete Message* button next to each message created by
673679
a user.
@@ -678,14 +684,14 @@ Summary
678684
=======
679685

680686
This short chapter gives you yet another way of building apps with
681-
nothing but JavaScript (and HTML and CSS, obviously). With Parse.com or
687+
nothing but JavaScript (and HTML and CSS, obviously). With Parse or
682688
a similar back-end-as-a-service (BaaS) solution, it is straightforward
683689
to persist the data without having to code your own back end. BaaS
684690
solutions event takes it a step further by allowing for access-level
685691
controls, authentications, server-side logic, and third-party
686692
integrations.
687693

688-
In addition to Parse.com, in this chapter we saw how Backbone can be
694+
In addition to Parse, in this chapter we saw how Backbone can be
689695
flexible in terms that you can overload its classes to build your own
690696
custom ones. This is a way to use Backbone to build your own framework.
691697
This is what we did at DocuSign where we had base Backbone models and
Collapse file

‎chapter5/media/board-1.png‎

Copy file name to clipboard
145 KB
  • Display the source diff
  • Display the rich diff
Loading

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.