Book Image

Learning Dojo

By : Peter Svensson
Book Image

Learning Dojo

By: Peter Svensson

Overview of this book

<p>Dojo is a popular AJAX-specific open-source JavaScript framework for building powerful web applications. It provides a well conceived API and set of tools to assist you and fix the issues experienced in everyday web development. Your project size is no concern while using Dojo. It is the best scalable solution to all your size-related issues.<br /> <br />This book starts by giving you tips and tricks for programming with JavaScript. These tricks will help you with Dojo. With every chapter, you will learn advanced JavaScript techniques. You will learn to leverage Dojo for a clean web application architecture using JSON or XML.</p>
Table of Contents (13 chapters)
Learning Dojo
Credits
About the Author
About the Reviewer
Preface
Free Chapter
1
Introduction to Dojo

OO in Dojo


Dojo has built its own inheritance-based system of object-orientation, on top of the prototype-based object orientation inherent in JavaScript. The system is used mainly for inheritance, to make it easy to write a base class for Buttons, and extend that to specific types of Buttons later on.

It also makes it simpler to convert code written in Java or other classically object-oriented languages. In contrast to many other object-oriented approaches, Dojo allows for multiple inheritance through mixins, which lets you copy the behavior from any number of base classes.

To declare a class using Dojo, you use the dojo.declare function:

dojo.declare ("MyNewClass", superclass,
{
});

Note that everything above is just a one-line function call which is broken down to several lines for pretty printing purposes. That's why theres a trailing left parenthesis at the end of the closing bracket.

It is very easy to forget to close the parenthesis, especially when you're writing your first classes...