100% found this document useful (1 vote)
5 views

KnockoutJS Starter 1st New edition Edition Eric M. Barnard instant download

The document provides information about the 'KnockoutJS Starter' book by Eric M. Barnard, which aims to teach readers the core concepts of KnockoutJS, a JavaScript library for building web applications using the Model-View-ViewModel (MVVM) pattern. It includes installation instructions, a quick start guide, and highlights key features of KnockoutJS. The book is designed to help developers create applications efficiently while maintaining a separation of concerns in their code.

Uploaded by

thawrazwaoui
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
5 views

KnockoutJS Starter 1st New edition Edition Eric M. Barnard instant download

The document provides information about the 'KnockoutJS Starter' book by Eric M. Barnard, which aims to teach readers the core concepts of KnockoutJS, a JavaScript library for building web applications using the Model-View-ViewModel (MVVM) pattern. It includes installation instructions, a quick start guide, and highlights key features of KnockoutJS. The book is designed to help developers create applications efficiently while maintaining a separation of concerns in their code.

Uploaded by

thawrazwaoui
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

KnockoutJS Starter 1st New edition Edition Eric

M. Barnard pdf download

https://ebookfinal.com/download/knockoutjs-starter-1st-new-
edition-edition-eric-m-barnard/

Explore and download more ebooks or textbooks


at ebookfinal.com
We believe these products will be a great fit for you. Click
the link to download now, or visit ebookfinal
to discover even more!

THE TEMPEST Starter Level 250 Word Vocabulary The Tempest


Dominoes Starter Level Starter 250 Headwords Shakespeare

https://ebookfinal.com/download/the-tempest-starter-level-250-word-
vocabulary-the-tempest-dominoes-starter-level-starter-250-headwords-
shakespeare/

In time Starter 1st Edition Amanda Thomas

https://ebookfinal.com/download/in-time-starter-1st-edition-amanda-
thomas/

How to Start a Business in New York Legal Survival Guides


2nd Edition Paul W. Barnard

https://ebookfinal.com/download/how-to-start-a-business-in-new-york-
legal-survival-guides-2nd-edition-paul-w-barnard/

Rock Mechanics New Research New Research 1st Edition M.


Abbie

https://ebookfinal.com/download/rock-mechanics-new-research-new-
research-1st-edition-m-abbie/
Pathology New Research New Research 1st Edition Julie M.
Vultagione

https://ebookfinal.com/download/pathology-new-research-new-
research-1st-edition-julie-m-vultagione/

Correspondence Analysis Theory Practice and New Strategies


1st Edition Eric J. Beh

https://ebookfinal.com/download/correspondence-analysis-theory-
practice-and-new-strategies-1st-edition-eric-j-beh/

Bilingual Children s Language and Literacy Development New


Zealand Case Studies Child Language and Child Development
4 1st Edition Roger Barnard
https://ebookfinal.com/download/bilingual-children-s-language-and-
literacy-development-new-zealand-case-studies-child-language-and-
child-development-4-1st-edition-roger-barnard/

Agricultural Policies New Developments New Developments


1st Edition Laura M. Contreras

https://ebookfinal.com/download/agricultural-policies-new-
developments-new-developments-1st-edition-laura-m-contreras/

Teacher Career Starter 2e 2nd Edition Edition Joan Della


Valle

https://ebookfinal.com/download/teacher-career-starter-2e-2nd-edition-
edition-joan-della-valle/
KnockoutJS Starter 1st New edition Edition Eric M.
Barnard Digital Instant Download
Author(s): Eric M. Barnard
ISBN(s): 9781782161141, 1782161147
Edition: 1st New edition
File Details: PDF, 3.85 MB
Year: 2012
Language: english
KnockoutJS Starter

Learn how to knock out your next app in no time


with KnockoutJS

Eric M. Barnard

BIRMINGHAM - MUMBAI
KnockoutJS Starter

Copyright © 2012 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system,
or transmitted in any form or by any means, without the prior written permission of the
publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers
and distributors will be held liable for any damages caused or alleged to be caused directly
or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies
and products mentioned in this book by the appropriate use of capitals. However, Packt
Publishing cannot guarantee the accuracy of this information.

First published: November 2012

Production Reference: 1161112

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham B3 2PB, UK.

ISBN 978-1-78216-114-1
www.packtpub.com
Credits

Author Proofreader
Eric M. Barnard Mario Cecere

Reviewer Graphics
Roy Jacobs Valentina D'Silva
Aditi Gajjar
Acquisition Editor
Mary Nadar Production Coordinator
Melwyn D'sa
Commissioning Editor
Yogesh Dalvi Cover Work
Melwyn D'sa
Technical Editor
Vrinda Amberkar Cover Image
Conidon Miranda
Project Coordinator
Amigya Khurana
About the author
Eric Barnard is a Software Engineer in Champaign-Urbana, Illinois. He truly feels that a great
day starts with a fresh pot of coffee and a blank JavaScript file on his computer screen.

Eric grew up on a farm in central Indiana, where he attended Purdue University. After graduating
from Purdue, he sharpened his web development and startup skills as a Fellow in the Governor
Robert Orr Fellowship in Indianapolis. At the time of this writing, Eric has recently got married
and spends his free time attempting to keep his wife sane. He is the author of the Knockout
Validation plugin and "KoGrid" a JavaScript DataGrid completely built on top of Knockout.
You can find his blog at http://www.ericbarnard.com.
About the reviewer
Roy Jacobs is a Software Architect in Utrecht, the Netherlands. Wrangling C# and JavaScript
is just as interesting as moving an icon two pixels to the left to improve the user experience.

Roy received his Bachelor's in Computer Science from the Fontys Polytechnic in Eindhoven and
his Master's in Human-technology Interaction from the Technical University of Eindhoven. Apart
from the technical stuff he dabbled in directing and visual effects and enjoys spending time with
his girlfriend and their hamster.

He is the author of the Knockout Mapping plugin and his blog can be found at
http://www.royjacobs.org.
www.PacktPub.com

Support files, eBooks, discount offers and more


You might want to visit www.PacktPub.com for support files and downloads related to
your book.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub
files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book
customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@
packtpub.com for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a
range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
www.PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book
library. Here, you can access, read and search across Packt's entire library of books.

Why Subscribe?
ÊÊ Fully searchable across every book published by Packt
ÊÊ Copy and paste, print and bookmark content
ÊÊ On demand and accessible via web browser

Free Access for Packt account holders


If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib
today and view nine entirely free books. Simply use your login credentials for immediate access.
Table of Contents
KnockoutJS Starter 1
So, what is Knockout? 3
Knockout – A JavaScript library 3
Knockout – A Model-View-ViewModel (MVVM) library 3
Installation 6
Step 1 – What do I need? 6
Step 2 – Create a starter site 6
Step 3 – Download Knockout 8
Step 4 – Create our main application JavaScript file 8
Step 5 – Run the application 9
Summary 11
Quick start 12
Business overview 12
Step 1 – Defining a namespace 12
Step 2 – Creating our Model 12
Step 3 – Creating a View for our Model 14
Step 4 – Creating a ViewModel to manage our Models 15
Step 5 – Working with Observable Arrays 15
Step 6 – Adding and removing Models from an Observable Array 16
Step 7 – Editing properties of a Model 18
Step 8 – Setting up a Master-Details view 19
Step 9 – Applying bindings 21
Summary 22
Table of Contents

Top features you need to know about 23


Subscribables 23
Observables 24
Observable Arrays 25
Computed Observables 27
Utilities 29
Data-bind statements 30
Applying bindings 31
Binding handlers 31
Summary 34
People and places you should get to know 35
Official sites 35
Articles and tutorials 35
Community 36
Blogs 36
Twitter 36

[ ii ]
KnockoutJS Starter

Welcome to KnockoutJS Starter. This book focuses on giving the reader a firm
understanding of the core concepts of Knockout, such as MVVM and data binding,
and works through real-life app development scenarios. All core components of
Knockout’s amazing library are covered in detail, and strategies are outlined for
getting the best use of time when developing with Knockout.
This book contains the following sections:

ÊÊ So, what is Knockout?– In this section you will get to know what Knockout does
and how you might start to benefit from its functionality.
ÊÊ Installation – In five easy steps, you will see how you can be ready to start developing
with Knockout.
ÊÊ Quick start – In this section you will learn to use Knockout to build an often needed
business tool – an inventory management app.
ÊÊ Top features you need to know about – This section illustrates Knockout’s numerous
extension points and plethora of utilities to help smooth the process of building
your app.
ÊÊ People and places you should get to know – Knockout’s core development team is
continually adding features and resources to help developers. You will learn, in this
section, how to access Knockout’s community and stay up to date in the future.
KnockoutJS Starter

So, what is Knockout?


In this section you will get to know what Knockout does and how you might start to benefit
from its functionality.

Knockout – A JavaScript library


Knockout, at its core, is a simple JavaScript file that can be included in a website or a web
application to add JavaScript functionality, and provides the ability to enhance a user's
experience. By default, Knockout does nothing to your website or web application until
you specifically write code to utilize it. It is important to understand the difference between
Knockout and many other JavaScript "frameworks" or "libraries" as some frameworks actually
change how a website or web application works when included.

Knockout – A Model-View-ViewModel (MVVM) library


One of the reasons that Knockout was created was for the specific goal of enabling
Model-View-ViewModel (MVVM) style development for websites and web applications.
MVVM is a style of development where different object classes are designed to separate
user-interface logic from business functions for testability purposes.

We strive to write testable code for many reasons (which is a topic for an entire other book),
but the biggest reasons are maintainability of the code base and improved quality assurance.
As I've learned to write code in a testable way, I've seen my code bases become more idiomatic
and easier to maintain. If anything, building JavaScript applications with the MVVM pattern
has allowed me to deliver more reliable applications in a shorter time period compared to when
I was simply trying to sprinkle my HTML pages with DOM event handlers and unorganized
pieces of logic.

ViewModel

View
Model

3
KnockoutJS Starter

The preceding diagram illustrates the common components and communication flow of an
MVVM architecture. We can see that Models, Views, and ViewModels are the building blocks
that we have to understand in order to derive benefit from the MVVM pattern. The first principle
of a MVVM-style application is defining the business Models. A Model is an object that usually
most directly represents a real-world object in the business system you are working in. It contains
properties and functions that have business-like names and reactions. If you were to make a Model
that represented an automobile, it would have properties such as:

ÊÊ MaxSpeed (Number)
ÊÊ TireSize (Number)
ÊÊ ManufacturerName (String)

It would also have functions such as:

ÊÊ Honk
ÊÊ DriveForward

The second principle of a MVVM-style application is the View. A View is the HTML markup that
describes the layout, elements (buttons, textboxes), colors, and other visual pieces of a portion
of the user interface. It has no logic or code embedded in it, and it is completely declarative
(all needed parts of the view are described purely in the HTML markup).

The third part of a MVVM-style application is the ViewModel. The ViewModel provides the
connection between the View and the Model. If you were making a ViewModel for a View
that was designed to display automobiles, it might have properties such as:

ÊÊ AutomobileCollection (Array)
ÊÊ SelectedAutomobile (Object)

And it would have functions like:

ÊÊ AddAutomobile
ÊÊ SortAutomobiles

4
KnockoutJS Starter

The ViewModel really allows you to keep business logic in your Model objects and create
the logic needed to power the user interface inside itself. The term for this is "Separation
of Concerns" and is incredibly useful with large (and small) web application architectures.

The final principle of MVVM is the concept of Binding. Binding is the idea of connecting the
properties and events of user interface elements (such as HTML elements) to functions and
properties of an object such as a ViewModel. An example of a binding would be the need to
connect a AddAutomobile button in the user interface with the ViewModel's AddAutomobile
function, or perhaps even connecting many user interface buttons to the single AddAutomobile
function on the ViewModel.

As Views in an MVVM application are almost always declarative in nature, bindings are often
declared in the View markup. Knockout is no different, and heavily utilizes HTML-compliant
"data-bind" declarations on HTML elements to enable its binding system.

The beauty of a solid MVVM library such as Knockout is that you can focus on developing the
business logic and critical functionality that your application or website needs rather than
spending critical time writing code to attach/detach event handlers and manually update
textboxes when data values change.

5
KnockoutJS Starter

Installation
In five easy steps, you can be ready to start developing with Knockout!

Step 1 – What do I need?


At the very least you will need the following in order to keep up with the examples in this guide:

ÊÊ A web browser
ÊÊ A text editor
ÊÊ Roughly 2 megabytes (MB) of space on the computer of your choice
ÊÊ A basic web server (explained as follows)

Knockout development can be performed on most operating systems as long as you can install
and use the tools listed above.

For the purpose of this guide we will be using Google Chrome as my web browser. It is free and
can be installed on both, Windows and Mac operating systems. You can find it at http://www.
google.com/chrome. My text editor of choice will actually take care of both my need for a text
editor and a webserver. I will be using Microsoft's WebMatrix development tool. It is free and
works on Windows operating systems. It can be downloaded from http://www.microsoft.
com/web/webmatrix/. I will be using the IIS Express as the basic web server. It can be
downloaded from http://www.microsoft.com/en-us/download/details.aspx?id=1038.
If you have a Mac or Linux operating system, there are many great text editors and web servers
out there that you can download and install for free.

Step 2 – Create a starter site


Now that we have our tools, we need to create a workbench for our application. I use the term
"workbench" as we will be creating and editing many different files as we work through this
guide. Some will be used simply for learning, while others will be part of the final application.
To start, I generally recommend creating a folder in a well-known spot (such as your computer
Desktop) to contain all of the files and folders that we will be using. My folder will usually end up
looking something like the following diagram:

/Site

/css
(various css files)

/JS
(various js files)

Index.html

6
KnockoutJS Starter

The JS folder will house all of our JavaScript files, and the CSS folder will house any CSS files
that we use in our Knockout app. We can create this site structure in a number of ways, but my
favorite way is to just visit http://html5boilerplate.com/ and download their starter site.
It provides a site structure (or Boilerplate) that includes many of the things you wouldn't want
to try and remember how to do (such as including a robots.txt file for your site).

Once you've created your Site folder, make sure to create a Index.html file. For the purpose
of this guide, ours will start out looking like the following HTML:
<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="utf-8" />
<title>Knockout Starter Guide</title>
<!-- CSS Here-->
</head>
<body>
<div id="content">
<p>Hello World!</p>
</div>
<!-- JavaScript Files Here -->
</body>
</html>

This will be the starting point for developing our app. We have left placeholders for our JavaScript
and CSS files, and we have created a "Content" area for the majority of our markup to be placed.

7
KnockoutJS Starter

Step 3 – Download Knockout


Now the magic starts. In order to build a Knockout app, we obviously need to have the Knockout
JavaScript library, and the best way to do that is to just download it from the Knockout website
at http://www.knockoutjs.com/.

Once you are on the Knockout website, just click on the Download / Install link at the top of the
page, and follow the instructions on that page.

For the purposes of this guide, we will want to use the Knockout-2.1.0.debug.js
JavaScript file, and we will want to put it in the JS folder that we created earlier.

Step 4 – Create our main application JavaScript file


Now we need to create a JavaScript file that will house all of the code for our application. We will
create a App.js JavaScript file and place it in the JS folder of our site. To start, this file will just
be an empty JavaScript as seen in the following sample:
// main application code here

Now that we have Knockout downloaded and our main application JavaScript file created, we
need to include them in our Index.html page. When including JavaScript files, we simply add
them to the HTML of our page using the traditional HTML script tag. The following HTML
example illustrates how we use these at the bottom of the page to reference our JavaScript files.

8
KnockoutJS Starter
<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="utf-8" />
<title>Knockout Starter Guide</title>
<!-- CSS Here-->
</head>
<body>
<div id="content">
<p>Hello World!</p>
</div>
<!-- JavaScript Files Here-->
<script type="text/javascript" src="/JS/knockout-2.1.0.debug.
js"></script>
<script type="text/javascript" src="/JS/App.js"></script>
</body>
</html>

We are referencing these scripts at the bottom of the page for a few reasons. The first reason
is that it allows the page to appear to render faster to the end user because the entire visual
markup is processed before the script references are, and thus will be displayed on the web
browser's screen while the referenced JavaScript files are downloading and being processed into
the browser's memory. Secondly, Knockout is a library that works with the browser's Document
Object Model (DOM), and in order to do so, the browser needs to have created and rendered the
content portions of the DOM before Knockout executes. Many other very good reasons exist as
to why JavaScript files are referenced at the bottom of an HTML page, but that discussion is a
bit out of scope for this guide. So, simply as a best practice we place our JavaScript files at the
bottom of the page in order to give our users the best experience possible.

Step 5 – Run the application


Now that we have our new site set up, let's run it and make sure everything works. As I am using
WebMatrix, I can just select the Index.html file and click on Run (on my Windows computer).
If you are using a different webserver, just start it with the root of the site being the site folder
that we created in the Step 2 – Create a starter site section, and then point your web browser at
the local URL your webserver is serving from.

9
Discovering Diverse Content Through
Random Scribd Documents
“Look at the dome of that cathedral,” I went on. “Could you set
to work and, in a single night, build a vast piece of architecture like
that, so many times higher than yourself?”
“That ain’t no cathedral,” said he.
“Have you ever seen a cathedral?” I asked.
“No.”
“Well, then, how do you know it isn’t?”
He could give me no reply and I continued in my enthusiasm—
“Look at that street, cut through all obstacles, leading straight as
though a thousand instruments of latter-day science had been used
in the making of it. Look at this avenue turning to right and to left.
Do you see that great cluster of buildings, a very parliament of
houses, set round a vast space that would shame the great square
of St. Peter’s, in Rome. Only look at the——”
I turned round and he had gone. I could see his figure retreating
in the distance. Every moment he turned his head, looking round, as
one who is pursued yet fears to show his cowardice by running
away. He thought I was mad, I have no doubt. Every one thinks you
mad when you say the moon is a dead world or the sun is a fiery
furnace. To be sane, you must only remark upon the coldness of the
moon, or the warmth of the sun. To be sane, you must speak of the
things of this world only in terms of people’s bodies. They do not
understand unless.
And so, when the man left me, I was alone, looking over the
wonderful city. For an hour then, I amused myself by naming the
different streets, by assigning to the various buildings the uses to
which it seemed they might be put.
That huge edifice with the cupola of bronze was the Cathedral of
Shadows, where prayers were said in darkness and never a lamp
was lit. The street which led to its very steps, that was called the
Street of Sighs. Here, in a lighter part of the city, approached to its
silent doors by Tight Street, was the Bat’s Theatre, where you could
hear, but never see the performance as it progressed. A little further
on there was Blind Alley—a cul-de-sac, terminating in a tiny building,
the Chapel of Disappointment. There was the Avenue of Progress,
the Church of Whispers, the Bridge of Stones and a thousand other
places, the names of which went from me no sooner than they
crossed my mind.
It may be possible to build a wonderful city in a night. I only
know how utterly impossible it is to name all its streets and its
palaces in one day.
And then, while I was still thus employed, I saw the man
returning with a jug of beer.
I nodded to the vessel which he carried in his hand.
“You don’t need to think about that,” said I, “to understand it.”
A broad grin spread across his face. He had found me sane after
all. I had talked about beer in terms of bodily comfort.
“I need to drink it,” said he with a laugh.
“You do,” said I.
Then, as if to appease me for the moment e’er he passed on his
way, he returned to our former subject and, with a serious voice, he
said—
“When yer come to think of it,” said he, “it do seem wonderful
that them moles is blind.”
“Not so blind,” said I, looking down at the wonderful city, “not so
blind as those who can see.”
He thought I had gone mad again, and he walked away with his
jug of beer.
IV
BELLWATTLE AND THE LAWS OF GOD
IV
BELLWATTLE AND THE LAWS OF GOD

I often wonder why God evolved a creature so antagonistic to all His


laws as woman. I must tell you what I mean.
Bellwattle—she is named Bellwattle for the simple reason that
one day in an inspired moment, she called her husband Cruikshank,
and he replied giving her the name Bellwattle, quite foolish except
between husband and wife—Bellwattle has the genuine mother’s
heart for animals. Everything that crawls, walks or flies, Bellwattle
loves. Some things, certainly, she loves more than others; but for all
she has the deep-rooted, protective instinct. Spiders, for example,
terrify her; flies and beetles she loathes, but would not kill one of
them even if they crawled upon her dress. And they do.
Now Bellwattle has a garden which she loves. You can see
already, if you have but the mind for it, the tragic conflict which,
with that love of her flowers, she must wage between her own soul
and the laws of God.
For this, I must tell you, is a lovely garden—not one of those
prim-set portions, with well-cut hedges and beds in orthodox array.
It is an old garden that has been allowed to run to ruin and
Bellwattle, possessing it in the nick of time, has planted primroses
amongst the nettles; has carved a little herbaceous border where
once potatoes grew. She has thrown roses here, there, and
everywhere and, in soap and sugar boxes covered with glass at the
bottom of the garden under the nut trees, she forces the old-
fashioned flowers that we knew—you and I—in the long-ago days
when sweet-william and candytuft were things to boast about and
foxgloves grew like beanstalks up to heaven.
But perhaps the most glorious thing in Bellwattle’s garden, that
also in which she takes the greatest pride, is her hedges of sweet
pea. They grow in great walls of dazzling colour, and the bees hum
about them all day long. But they are the devil and all to raise.
Now this is where the tragic conflict comes in, between the mice
and the birds and the slugs and Bellwattle’s kitten and Bellwattle’s
heart. It is a terrible conflict, I can tell you; for the laws of God are
unalterable, and so is the heart of Bellwattle.
This, then, is what happens: Bellwattle forgot to cover the sweet
pea seeds with red lead. It is just the sort of thing a woman would
forget. I doubt if I could think of it myself. Then followed the natural
result. A shrew-mouse got hold of one or two of them, and
Bellwattle wondered why on earth God ever made shrew-mice.
“But they’re dear little things,” I told her.
“I can’t help that,” said she. “What’s the sense in making a thing
that goes and eats up other things?”
Which, of course, was unanswerable.
Two days after this had happened, the kitten was seen playing
with a live shrew-mouse.
Bellwattle screamed.
“Oh, the little wretch! If I could only catch it!”
“What—the mouse?” shouted Cruikshank.
“No, no; the wretched little kitten! Look at the way she’s
torturing it! Oh, I never saw such a cruel little beast in all my life!”
and her face grew rosy red.
Now, Cruikshank is a dutiful husband. Moreover, he knows
positively nothing about women. Perhaps that is why. When,
therefore, he realised that it was the kitten who was the cruel little
beast, and a sense of duty claiming him, he chased it all over the
garden, picking up stones as he ran.
“Make her drop it!” cried Bellwattle.
“I will, if I can hit her,” replied Cruikshank and, like a cowboy
throwing a lasso from a galloping horse, he flung a stone. The kitten
was struck upon the flank and in its terror it dropped the mouse and
fled. Cruikshank approached it and, he assures me, with much pride
in his prowess picked up the poor little mouse by the hind leg. Then
he looked up and saw Bellwattle’s face. It was white—ashen white.
“You’ve hurt her,” she said, half under her breath.
“It’s better than hurt,” said Cruikshank—“it’s dead.”
“No—the kitten—you hit it with a stone.”
“’Twas a jolly good shot,” said Cruikshank.
“I never meant you to hit her,” said Bellwattle.
Cruikshank looked disappointed. To hit a flying object whilst one
is in a tornado of motion one’s self is no mean feat. Failing an
appreciation of the woman herself, I am not surprised he was
disappointed.
“I made her drop it, anyhow,” he said.
“You’ve frightened her out of her life and now perhaps she’ll
never come back,” said Bellwattle, and in and out of the garden she
went, all through the forests of rhododendra—where the kitten, I
should tell you, hunts for big game—and with the gentlest, the
softest, the most wooing voice in the world, she cried the kitten’s
name. Cruikshank was at a loss to understand it. When he met her
down one of the paths still calling, with tears in her eyes, he assures
me he felt so ashamed of himself that he began, in a feeble way,
calling for the kitten too. When they met again, still unsuccessful in
their search, he dared not look her in the face.
Now this is only one of the conflicts that take place in Bellwattle’s
soul. She worships the birds, but they eat the young shoots of the
sweet peas. Then she hates them; then the kitten catches one. And
now, Cruikshank tells me, he will have no hand in the matter.
“You leave it to God,” I advised.
“I do,” said he; “it’s too difficult for me.”
I believe myself it is too difficult for God.
Only the other day, in the farmyard, Bellwattle saw two cocks
fighting—fighting for the supremacy of the yard. Cruikshank and I
looked on, really enjoying the sport of it in our hearts, yet deadly
afraid of saying so.
“Can’t you stop them?” exclaimed Bellwattle. “They’re hurting
each other!”
We neither of us moved a hand.
“If you don’t, I shall have to go and do it myself,” said she.
“Much better leave it to God,” said I. “They’re settling matters
that have nothing to do with you.”
But do you think logic so profound as that deterred her? Not a bit
of it! Out she ran into the farmyard, throwing her arms about in the
air—as women will when they wish to interfere with the laws of God.
“Shoo! shoo! shoo!” shouted Bellwattle.
And one of the cocks, at the critical moment of victory,
reluctantly leaving go of its opponent’s comb, looked up with
considerable annoyance into her face and shrieked back—
“Cock-a-doodle-do!”
Cruikshank glanced at me out of the corner of his eye, and out of
the corner of his mouth he whispered—
“We shan’t have any eggs to-morrow.”
V
REALISM
V
REALISM

This word—realism—has lost its meaning. So, for that matter, has
many another word in the language. Sentiment is one and, as a
natural consequence, the word sentimental is another. Realism and
sentiment, in fact, have got so shuffled about, for all the world like
the King and Queen in a pack of cards that now, instead of
sentiment being hand in hand with reality, they have become almost
opposed. To express a sentiment is now tantamount to ignoring a
reality.
Joseph Surface may be responsible for this. It would not seem
unlikely. But wherever the responsibility lies, it is an everlasting pity;
no one has had the common politeness to replace or even create a
substitute for the thing which they have taken away.
Realism, which now means an expression of things as they
happen without any relation to things as they immortally are, is
robbed of its true significance. But no word is left in its place.
Sentiment, which now means an expression of momentary
emotionalism, instead of what one perceives to be true in the
highest moments of one’s thoughts, has left a blank in the language
which no one seems willing to or capable of filling up.
Now all this is an irreparable loss. How great a loss it is can be
seen by the fact that no two people’s terminology is the same when
they are discussing a subject wherein these words must be
employed. In the space of five minutes both are at cross purposes;
in a tangle from which they find it well-nigh impossible to extricate
themselves.
I do not for one instant propose to supply here a solution to the
difficulty; nor can I coin two words to repair the loss sustained. All I
wish to do is to tell a real story, one that happened only a short
while ago, to illustrate what seems to me to be realism in
comparison with what realism is supposed to be.
Our little servant-girl was married—married to the young man
who brought the milk of a morning. The courtship had been going
on for some time before I realised the glorious things that were
happening. Then, when I was told about it, I used to peep out of my
bedroom window. As soon as I heard that cry of his—impossible to
write—when he opened the gate and rattled with his can down the
area steps, then up I jumped from my bed and lifted the window.
They must have been wonderful moments for Emily, those early
mornings when, with heart beating at the sound of his cry, she had
run for the big white jug, then dragged out the time lest he should
think she had opened the door too eagerly.
Many a time have I seen them down at the bottom of those area
steps; she leaning up against the pillar of the door watching him,
rapt in admiration, while he filled up the big white jug.
It is a fine thing for you when your little maid has eyes for the
milkman. You get a good measure, I can tell you. He would not
seem stingy to her for the world. I have seen him dipping his little
half-pint measure times and again into the big can as he talked to
her and, as she held out the white jug, just trickling it in till our two
pints were more than accounted for.
All this went on for weeks together. Emily sang like a lark in the
morning when she rose betimes to do her work. The worst of the
scrubbing was all finished with and Emily’s hair was tidy long before
there came that weird falsetto cry, or the sound of the milk cans
rattled down the area steps. Oh, I can assure you, it is an excellent
thing when your little maid has eyes for the milkman. She never gets
up late of a morning.
And then, at last, with great to-doings in Emily’s home out at
Walham Green, they were married. I asked Emily what she would
like for a wedding present and she said:
“I’d like one o’ them old brass candlesticks—same as what you
’ave in your study.”
You see Emily had acquired some taste. I call it taste because it
is mine. Good or bad, she had acquired it.
“Wouldn’t you prefer silver?” I asked, thinking I knew what silver
would mean in Walham Green.
But she only replied:
“No—I like the brass ones—’cos they’re old. I’ve a fancy for old
things.”
So a pair of old brass candlesticks was what I gave her. She
wrote and thanked me for them. She said they looked just lovely on
George’s writing table and that one of these days, when I was
passing that way, I ought to go and look at them.
I did pass through Walham Green eventually. It was some
months later. She had probably forgotten all about having asked me,
but I paid my visit all the same.
For a moment or so, as I stood on the doorstep, I felt a twinge of
trepidation. I could not remember her married name. But it was all
right. She opened the door herself. Then, as she stood there, with a
beaming smile lighting her face from ear to ear, reminding me so
well of those early mornings when I used to peep out of my
bedroom window and peer into the area below, I saw that soon
there would be another little Emily or another perky little George to
bring a smile or a cry into the world.
“You’re happy?” said I.
“Oh—sir!” said she.
She showed me up then to the sitting-room where was George’s
writing table and the pair of old brass candlesticks. She pointed to
the table.
“’E made it ’imself,” she said, not meaning it in explanation; but it
did explain the queer shape. “’E made it out of an old box and I
covered it with felt. Ain’t it splendid?”
I agreed with my whole heart. Everything was splendid. The
whole room might have been made out of an old box. And yet I
could see what a joy it was to her. There was her acquired taste in
evidence everywhere, but except for my poor pair of candlesticks,
everything was imitation. It made no matter. She thought they were
really old and liked them immeasurably better than the things I had
collected with such care at home.
“Could anything be nicer than this?” said I with real enthusiasm.
“I don’t believe it could, sir,” said she.
And then, in little half-amused, half-curious, half-frightened
whispers, she told me how they were going to call the baby after
me.
“Supposing it’s a girl,” said I.
No—they had not reckoned on that. When you make up your
mind properly to a boy—a boy it is up to the last moment. After that,
you forget how you made up your mind, you are so wildly delighted
that it is alive at all.
I walked across to the window.
“So you’re radiantly happy,” I said.
“’E’s just wonderful,” she replied; “I thought it couldn’t last at first
—but it’s just the same.”
I gazed out of the window—envious, perhaps.
“What does this look on to?” I asked.
“A slaughter-house, sir.”
She said it full of cheerfulness, full of the joy of her own life. I
stared and stared out of the window. A slaughter-house! A
slaughter-house! and here was a little slip of a woman passing
through those trembling hours before the birth of her first child!
Now that is what your realist would call a chance! He would
make a fine subject out of that. He would show you the growth of
that idea in the woman’s mind. He would picture her drawn to gaze
out of that awesome window whenever they dragged the lowing,
frightened cattle to their doom. And last of all, with wonderful
photographic touches, he would describe for you the birth of a still-
born child. Then with a feeling of sickness in the heart of you, you
would lay down the story and exclaim, “How real!”
That is what is meant by realism to-day.
Yet somehow or other I prefer my Emily; not because the boy is
called after me—but because, whatever he may be called, he is
alive, he is well, and he kicks his little legs like wind-mills.
Now that is an immortal truth.
VI
THE SABBATH
VI
THE SABBATH

When I was a little boy—younger even than I am now—my father


had strict ideas upon Sabbath behaviour. We might read nothing, I
remember, but what was true. Now, if you come to think of it, that
limits your range of literary entertainment in a terrible way. It drove
me to such books as “Little Willie’s Promise—a True Story” or “What
Alice Found—Taken from Life.”
One Sunday afternoon, perched high in the mulberry-tree, I was
found with a copy of the Saturday’s daily paper. It was smeared with
the bloodstains of many mulberries, whose glorious last moments
had been with me.
“What have you got there?” asked my father from below.
I told him. It was Sunday. My story at least was true.
“Come down at once!” said he.
I descended, finding many more difficulties to overcome than I
had discovered in my ascent.
My father waxed impatient.
“Can’t you get down any quicker than that?” he asked. He had a
book on rose-growing in his hand, which, being quite true, he was
taking out on that glorious afternoon to read and enjoy in the
garden.
With all respect, I told him that I did not want to break my neck
and I continued slowly with my laborious descent. When I reached
the ground, he eyed me suspiciously.
“How dare you read the paper on Sunday?” he asked.
“I was only reading the police reports,” said I, humbly; “I thought
they were true.”
He held out his hand expressively. I timidly put forth mine,
thinking he wanted to congratulate me on my taste.
“The paper!” said he, emphatically.
I yielded, without a word.
“Now, if you want to read on Sunday,” said he, “go into the house
and learn the Collect for the third Sunday after Trinity. And never let
me see a boy of your age reading the paper again.”
“Not on week-days?” said I.
“No, never!” he replied, and, as he walked away, he scanned the
Stock Exchange quotations with a stern and unrelenting face.
I do not want to argue about the justice of this, for now that I
am a little older, the after effect, though not what my father
expected, has proved quite admirable. If the newspaper was not
true enough to read on week-days, let alone Sundays, I came to the
conclusion that it must be very full of lies indeed. And all this has
been very helpful to me ever since. I think of it now as I open my
daily paper in the morning, and I thank my father for it from the
bottom of my heart. It has saved me a deal of unnecessary credulity.
I remember, too, that all games—all games but chess—were
strictly forbidden. That also has left an impression on my mind—an
ineffaceable impression about the game of chess. It seems a very
stern game to me—a game rigid in its expression of the truth. The
King and Queen are always real people, moving—far be it from me
to allude to Royalty—in straightened paths; the Queen impulsively,
the King in staid dignity, one step at a time. I always behold the
Knight as one, erratic and Quixotic in all he does; the Bishop swift
and to the point, thereby connecting himself in my mind with the
days when the Bishops went out to war and brought the Grace of
God with them on to the battlefield, rather than with the Bishops of
to-day, who keep the Grace of God at home.
So I think of the game of Chess—the only game we were ever
allowed to play on Sunday—the game my father loved so well above
all others.
I don’t know what it is about the observance of the Sabbath, but
to me it seems a beautiful idea, like a beautiful bell; yet a bell that
has been cracked and rings with a strange, false, unmeaning note.
No one seems to be able to get the true tone of it. Heaven knows
they ring it enough. The Church and such followers of the Church as
my father are always pealing its message for the world to hear; yet I
wonder how many people detect in it the sound of that discordant
note of hypocrisy.
Nevertheless, there is something grand in that conception of One
creating a vast universe in six days or six ages—whichever you will—
and resting at His ease upon the seventh. Nor is it less grand to
work throughout a common week, making a home, and on the
Sabbath to cease from labour. The whole world is agreed that that
day of rest is needed; but are they to lay down a law that what is
rest for one man is rest for another?
If that is the only way they can think of doing it; if that is the
only interpretation of the word—rest—which they can find, then, so
far as the Sabbath is concerned, we shall be a nation of hypocrites
or lawbreakers for the rest of our days. And of the two, may I be
one who breaks the law. For, do what you will with it, human nature
has reached that development when it insists upon thinking for itself
and, one man, thinking it all out most carefully, will declare that a
game of chess is not an abomination of the Sabbath, while another
will read the police reports in the daily papers because they are true.
Fifty years ago, Charles Kingsley, that strenuous apostle of
health, urged that it was better to play cricket on the Green at
Eversley than stay at home and be a hypocrite—or a gambler, which
is much the same thing. But his was only one honest voice amongst
the thousands of others who have preached a very different gospel
to that.
Only a short while ago, at a little tennis club in the suburbs of
London, there came up before the committee the question as to
whether play should not be allowed on Sunday. The club was
composed of city clerks, of members of the Stock Exchange, of men
labouring the daily round to keep together those homes of which
both the Church and the nation are so justly proud.
Every one seemed in favour of it, until the Vicar of the parish
rose and said that seeing there was a high fence all round the
ground, and that the players would be hidden from the sight of the
public at large, he saw no reason why play should not be allowed
out of Church hours—that was to say, from two till six.
“But,” said he, “I must most vehemently protest against any
playing of the game of croquet.”
A member of the committee, one with a lame leg, who was
debarred from tennis, but was known to make his ten hoop break at
croquet, asked immediately for the reason of this protest.
“I work all the week in the city,” said he; “I have no other chance
for playing except late on Saturday and on Sunday. Why should you
prevent croquet?”
“Because,” said the Vicar, “the sound of the croquet balls would
reach the ears of people passing by. And what do you imagine they’d
think if they heard people playing croquet? I make no objection to
tennis because, if played in a gentlemanly way, no one outside need
know that a game was going on—but croquet! You must remember
we have to consider others as well as ourselves.”
“You think it would make them feel envious?” asked the lame
man.
“I mean nothing of the kind,” said the Vicar.
“Then what do you imagine they would think?”
“They would realise that the Sabbath—the day of rest—was
being broken.”
“Then we have your consent to break it with tennis,” said the
Chairman.
“It seems to me,” said the Vicar, “that this discussion is being
carried into the region of absurdity.”
“I quite agree with the Vicar,” said the lame man.
VII
HOUSE TO LET
VII
HOUSE TO LET

If I only knew more about women than I do—if I only knew anything
about them at all—I might be able to understand the vagarious
indetermination of the lady who is contemplating the occupation of a
little house quite close to me here in the country.
But I know nothing about the sex—well, next to nothing. That is
as near to the truth as a man will get on this subject. His next to
nothing, in fact, is next to the truth. And so, with this open
confession of ignorance, I can explain nothing about this lady. I can
only tell you all the funny things she does.
There is this house to let. Well, it is less than a house. An agent,
flourishing his pen over the book of orders to view, would call it a
maisonette—what is more, he would be right. It is a little house—a
little, tiny house. The view from the balcony round the top of it is
beautiful; but from inside, I doubt if you can see anything at all. I
have never been inside, but that is what I imagine.
Now, the strange thing about this lady’s attraction for it is that
she has occupied it once before. There her children were brought
up. From there they were sent out into the world upon that
hazardous journey of fortune: that same journey in quest of the
golden apple for which the three sons have always set forth, ever
since the first fairy tale was written. And so the little house is filled
with recollections for her.
She remembers—I have heard her speak of it—the day when
Dicky, the youngest boy, fell out from one of the windows. Not a
long fall, but it was the devil and all to carry him back into the
house. She did not say it was the devil and all. I say it for her,
because I know when she was telling it, that was the way she
wanted to put it. But a woman can look a little phrase like that,
which is so much better than saying it.
She remembers also the day when they had nothing in the house
to eat and she, saying such things to her husband as God has given
him memory for the rest of his life, had to go out and scrape
together whatever she could find. It was a cold day. There was snow
on the ground. Snow in the beginning of May! Heaven only knows
how she managed. But she succeeded.
There is that about women. They will get food for their children,
even when famine is in the land, or they will die. I know that much
about them. They have died in Ireland.
Well, all these things she remembers; things which, softened by
time, are no doubt pleasant memories ere this. And yet she cannot
make up her mind. Where she has been since they went away, I do
not know. Travelling, I imagine. But here she is back once more,
doubtless worrying the life out of the house agent, who is
continually being jostled in the balance of thinking he has, then
thinking he has not, let a very doubtful property.
Every morning she comes and looks over the old place. I suppose
she is staying in the neighbourhood. From every side she views it
and all the while she talks to herself. Now, women do this more than
you would think. They do it when they are going to bed at night.
They do it when they are getting up in the morning. It always seems
as if there were some one inside them to whom they must tell the
truth, because, I believe, they are the most truthful beings in the
world—to themselves.
Only yesterday, when she thought she was absolutely alone, I
heard her saying—
“You wouldn’t like it, you know, once you were fixed up there
again. It’s out of the way, of course, quiet, but you wouldn’t like it.”
And then, having told herself the truth, she began immediately to
contradict it.
Why they do this is more than I can tell you. The only people
who can tell the truth, they seemingly dislike it more than any one
else. A man loves the truth, lives for it, dies for it, but seldom tells it.
With a woman it is just the opposite, and I cannot for the life of me
tell you why.
“You’d be a fool if you took it,” she said to herself as she went
away to the house agent’s. “You don’t know who you’ll have for
neighbours. They might be disgusting people.”
I followed her to the house agent’s, and this, if you please, was
the first question she put to him—
“What sort of people do you think’ll take the house over the
way?”
I pitied the house agent from the bottom of my heart, because
how on earth could he know? Yet upon his answer hung all his
chances of letting. I thought he replied very cleverly.
“They’re sure to be good people,” said he; “we only get the best
class round here.”
And then, just listen to her retort—
“But you can’t tell,” said she. “What’s the good of pretending you
know. It might be a butcher and his family. You couldn’t stop them if
they wanted the house.”
The agent leaned back in his chair, then leaned forward over his
desk, turning over pages and pages of a ledger.
“Well, will you take an order to view this one?” said he. “Same
rent—a little more accommodation.”
“No, I don’t want to see any more,” she replied. “This is the one I
like best.”
“Well, would you like to settle on that?” said the agent. “I’ll write
to the landlord to-night.”
“I’ll let you know to-morrow,” said she.
For three weeks she has gone on just like this.
And it is still to let, that little house in the bowl of my old apple
tree. But every morning she comes just the same and, sitting on the
topmost branch, she chatters to herself incessantly for half an hour,
as starlings and women do—for she is a lady starling. I shall be
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookfinal.com

You might also like