Servis-Rhino 4211B Betriebsanweisung Seite 147

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 298
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 146
milliseconds – A boolean. If selected, milliseconds will be included.
See also:
Dates and times within JSON
Dijit Widgets
In modern UI environments, we usually do not build our UI pixel by pixel. Instead, we assumed
that there exist rich and high level building blocks. These building blocks are so common to us now
that we take their existence for granted. Examples of such building blocks include buttons, menus,
dialogs and select boxes. In addition, there are even richer building blocks such as rich text editors,
calendars, charts and many more. Dojo provides an enviable collection of pre-defined building
blocks that it calls "widgets". These widgets are, for the most part, packaged as part of the "dijit"
package namespace.
Dijit widgets are re-usable components for building web pages. Some components are supplied by
the Dojo package, some by vendors and we can also write our own widgets. Each widget has a set
of common attributes:
id – The id of the widget. This must be a unique id that belongs to the widget. No two
widgets on the page may have the same id. If no explicit id is provided when the widget is
created, a unique id will be generated for it.
style – The HTML style attribute of the widget.
title – The title of the widget.
class – CSS class information to apply to the widget.
Widgets can be created either programatically or declaratively by HTML in the page.
Creating a widget instance programatically
A widget can be created programatically within JavaScript by creating a new instance of the object
associated with the reference returned when its corresponding package is loaded. This is a mouthful
so let us look at this concept closer and by example. Imagine that we wish a Dojo button to be
added into our web page. Having familiarized ourselves with the summary of widgets available, we
see that a button is provided by the widget called "dijit/form/Button".
In our JavaScript code, we will then load the module that corresponds to that Dojo function. We
will do this with code similar to the following:
require(["dijit/form/Button"], function(Button) {
// Code goes here...
});
We read this as "We require the Dojo module called 'dijit/form/Button' so please load it.
When loaded, you will return me a reference to it as the first parameter of a function. That function
will store that reference in a variable that I choose to call 'Button'".
There is nothing magic in the variable being called 'Button' but what else should we call it that
actually makes better sense? Calling it 'Menu' would be the height of madness as what it actually is
is a reference to a template that creates Buttons.
Now that we have a reference to the template that can create buttons, we can create an instance of a
button with code such as:
var myButton = new Button();
Hooray!! … well … not quite so fast. Although the variable "myButton" now contains a concrete
Page 147
Seitenansicht 146
1 2 ... 142 143 144 145 146 147 148 149 150 151 152 ... 297 298

Kommentare zu diesen Handbüchern

Keine Kommentare