Hands-on Dijit with NumberSpinner
This section provides some hands-on usage for a pretty intuitive
dijit—the dijit.form.NumberSpinner
—to warm you up for the chapters that follow. First, we'll work
through creating the dijit in markup, and then we'll follow up with
programmatic creation.
Creating from Markup
As you learned from an earlier section on the parser, it's
pretty trivial to stick a dijit into the page. You require in the
resources, provide the dojoType
attribute in a tag, and have the parser go to work. For
completeness, Example 11-4
shows how we'd follow that very same pattern to instantiate a
NumberSpinner dijit.
Example 11-4. Creating the NumberSpinner widget in markup
<html>
<head>
<title>Number Spinner Fun!</title>
<link rel="stylesheet" type="text/css"
href="http://o.aolcdn.com/dojo/1.1/dojo/resources/dojo.css" />
<link rel="stylesheet" type="text/css"
href="http://o.aolcdn.com/dojo/1.1/dijit/themes/tundra/tundra.css" />
<script
type="text/javascript"
src="http://o.aolcdn.com/dojo/1.1/dojo/dojo.xd.js"
djConfig="parseOnLoad: true"
></script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dijit.form.NumberSpinner");
</script>
<head>
<body class="tundra">
<form> <!-- some really awesome form -->
<input dojoType="dijit.form.NumberSpinner"
constraints="{min:0,max:10000}" value=1000>
</input>
</form>
</body>
</html>Programmatic Creation
While you'll often create dijits in markup, programmatic creation is no less common and the process is the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access