.. _dijit/Declaration: dijit.Declaration ================= :Status: Draft :Version: 1.0 :Project owner: Bill Keese :Available: since V1.2 .. contents:: :depth: 2 Declares a widget from markup. ============ Introduction ============ Just as there are two ways to create a widget instances - declarative and programmatic - so there are two ways to declare a Dijit class (i.e., a type of widget). As you might guess, the declarative way is slightly easier. ===== Usage ===== To declare your class declaratively, use dijit.Declaration. Uhhhh, OK, too many "declare"s in that sentence. It's easier to show than to tell. Here's an example defining a widget called Employee, and then creating two of those Employee widgets: .. cv-compound:: .. cv:: javascript .. cv :: html
Note that it's defining two widget parameters: * empid: Number * name: String And then it's defining a template .. code-block:: html ${name} update delete And finally that it's using the widget parameters name and empid in the template, as the substitution variables ${name} and ${empid}. Dijit.Declaration turns this markup into a templated widget class. The code doesn't display anything itself, so it's best to place it right after the BODY tag before any displayable code. Methods, dojoAttachPoint, and dojoAttachEvent --------------------------------------------- The example below defines a widget named "HideButton" that will hide itself when clicked, and then creates two HideButtons: .. cv:: html