Chapter 12. Dijit Anatomy and Lifecycle
Like object-oriented concepts from any other programming paradigm, Dojo widgets—dijits—follow particular patterns for lifecycle events such as creation and destruction, are composed according to a particular an anatomical style, and are described by a somewhat specialized vocabulary. This chapter provides a summary of these topics with an extended discussion on the fundamentals of custom dijit design.
Dijit Anatomy
Although you already know that dijit is short for "Dojo widget,"
it's helpful to elaborate just a bit before we proceed any further. To
be precise, a dijit is any Dojo class that inherits from a
foundational class from Dijit called _Widget. This class is part of the toolkit's
foundational dijit module, so the
fully qualified name of the class is dijit._Widget. There are several other
foundational classes from Dijit that you'll learn about, but _Widget is the one that provides the primary
ancestor for any dijit.
As you learned in Chapter 10, dojo.declare saves you from writing a lot of
mundane boilerplate; dijits follow suit by tucking away a lot of
complexity in classes like _Widget.
As you're about to see, there are a number of method stubs that you
can override to achieve custom behavior, as opposed to engineering
your own boilerplate.
Tip
You may be wondering why the _Widget class is prefixed with a leading underscore. When used in relation to dijits, the leading underscore almost always means that it should not be instantiated on ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access