Servis-Rhino 4211B Betriebsanweisung Seite 148

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 298
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 147
instance of a button, nothing at all will be shown in the web page. We haven't told the button where
on the page it should appear. This is a core notion. Creating a widget does not cause it to appear.
We must also tell the widget where on the page it should be located. To do this, we must associate
the widget with a DOM node. Think of the DOM node as being an anchor on the page that
describes where the widget should appear.
We have a couple of ways to associate a widget with the desired target node. The first is to pass the
node as a parameter when the widget is constructed. Most widgets allows a node to be supplied at
this time. It is common that this is the second parameter on the widget's constructor. For example:
var myButton = new Button({label: "Press Me"}, "myNode");
The target node can be supplied either as the "id" of the target node or as a reference to a node
object.
If we don't want to supply the node when the widget is created, we can usually call a method that
will be found on the widget called "placeAt()" which takes as a parameter the node against
which the widget should be placed.
In the example above, we also snuck in a second new concept. Every widget we will work with has
properties associated with it. These properties control how it looks and behaves. When a widget is
constructed, the first parameter on its constructor is a JavaScript object that has properties that will
be used to set the corresponding named properties of the widget. In the example above, the Button
widget has a property called "label" which describes the label shown on the button.
dijit/registry - Dijit and byId
When a Dijit widget is created, it can be supplied an "id" attribute than can then be used to find the
reference to the widget by its id value using registry.byId("<id>"). Note that the id value
has to be unique on the page. If no id value I supplied, Dojo will generate a unique id.
If we don't know the id value, we can still retrieve a reference to the widget if we know the DOM
node against which it is attached. A second function called "registry.byNode(<node>)"
can be used which will return us a reference to the widget if all we know is a DOM node.
Another extremely useful capability of the registry is to create unique Ids. For example:
registry.getUniqueId(this.declaredClass)
Dijits and events
We can connect a Dijit widget to its events. For example:
connect.connect(myButton, "onClick", this, myFunction);
however, this technique is being deprecated. The newer technology is to use the dojo/on
technique.
See also:
dojo/on – 1.7
Events with Dojo – 1.7
Sitepen - dojo/on: New Event Handling System for Dojo – 2011-08-03
Dojo style sheets and themes
Dojo provides a number of themes and styles that are used to provide a default look and feel to a
Page 148
Seitenansicht 147
1 2 ... 143 144 145 146 147 148 149 150 151 152 153 ... 297 298

Kommentare zu diesen Handbüchern

Keine Kommentare