.. _dijit/_Widget: dijit._Widget ============= :Status: Draft :Version: 1.0 :Project owner: Bill Keese :Available: since V0.9 .. contents:: :depth: 2 ============ Introduction ============ dijit._Widget is the base class for all widgets in dijit, and in general is the base class for all dojo based widgets. Usually widgets also extend other mixins such as :ref:`dijit._Templated `. Note that the underscore in the name implies not that _Widget is a private class, but rather that it's a base class, rather than a widget directly usable. ===== Usage ===== All widgets are created by calling dojo.declare(), extending from _Widget: .. code-block :: javascript :linenos: and then redefining a number of methods for the widget lifecycle... ========= Lifecycle ========= The lifecycle of a widget decribes the phases of its creation and destruction which you can hook into. It's useful to understand exactly what happens when. Whether you are sub-classing an existing widget, using dojo/method script blocks, or passing in method overrides to the constructor, these are your entry points for making a widget do what you want it to do. Widgets are classes, created with dojo.declare. All widgets inherit from dijit._Widget, and most get the _Templated mixin. That provides you the following extension points (methods) you can override and provide implementation for: - constructor Your constructor method will be called before the parameters are mixed into the widget, and can be used to initialize arrays, etc. - parameters are mixed into the widget instance This is when attributes in the markup (ex: