i'm trying to make a menu, I cant even run this example code for some reason! The error on firbug is :
Could not load class "dijit.DropDownMenu"
Every other dojo menu related class is working, i tested that by removing parts of the code below to see if anything else is not rendering.
<div data-dojo-type="dijit.MenuBar" id="actionMenu">
<div data-dojo-type="dijit.PopupMenuBarItem">
<span>File</span>
<div data-dojo-type="dijit.DropDownMenu" id="fileMenu">
<div data-dojo-type="dijit.MenuItem" data-dojo-props="onClick:function(){alert('file 1');}">File #1</div>
<div data-dojo-type="dijit.MenuItem" data-dojo-props="onClick:function(){alert('file 2');}">File #2</div>
</div>
</div>
<div data-dojo-type="dijit.PopupMenuBarItem">
<span>Edit</span>
<div data-dojo-type="dijit.DropDownMenu" id="editMenu">
<div data-dojo-type="dijit.MenuItem" data-dojo-props="onClick:function(){alert('edit 1');}">Edit #1</div>
<div data-dojo-type="dijit.MenuItem" data-dojo-props="onClick:function(){alert('edit 2');}">Edit #2</div>
</div>
</div>
Can anyone point out why? I've used the follwoing require statements
dojo.require("dijit.MenuBar");
dojo.require("dijit.PopupMenuBarItem");
dojo.require("dijit.DropDownMenu");
dojo.require("dijit.MenuItem");
You haven't provided the information on how you get the library reference nor the version. So I'll assume it's googleapi's as that was the only way to get similar error.
The truth is, that while you reference the library from let's say googleapi's it doesn't work. I've tried to use 1.6 and less down to 1.2. No luck. Simply, that reference to dojo library doesn't contain a DropDownMenu definition.
The solution is to not use the googleapis :) Download the source cod version of Dojo from their download page and use the reference to that build. It worked for me for version 1.7.2. Or use some other links rather than google's
Hope this helps.
<html>
<head>
<link rel="stylesheet" type="text/css" href="dojo172/dijit/themes/claro/claro.css" />
<link rel="stylesheet" type="text/css" href="dojo172/dojo/resources/dojo.css" />
<script type="text/javascript">djConfig = { parseOnLoad:true, isDebug:true };</script>
<script type="text/javascript" src="dojo172/dojo/dojo.js"></script>
<script>
dojo.require("dijit.DropDownMenu");
dojo.require("dijit.MenuItem");
dojo.require("dijit.MenuSeparator");
dojo.require("dijit.PopupMenuItem");
dojo.require("dijit.MenuBar");
</script>
</head>
<body class="claro">
<div data-dojo-type="dijit.DropDownMenu" id="navMenu">
<div data-dojo-type="dijit.MenuItem" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconCut',
onClick:function(){alert('drama!')}">Drama</div>
<div data-dojo-type="dijit.MenuItem" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconCopy',
onClick:function(){alert('comedy!')}">Comedy</div>
<div data-dojo-type="dijit.MenuItem" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconPaste',
onClick:function(){alert('romance!')}">Romance</div>
<div data-dojo-type="dijit.MenuSeparator"></div>
<div data-dojo-type="dijit.PopupMenuItem">
<span>Action</span>
<div data-dojo-type="dijit.DropDownMenu" id="submenu2">
<div data-dojo-type="dijit.MenuItem" data-dojo-props="onClick:function(){alert('diehard!')}">Diehard</div>
<div data-dojo-type="dijit.MenuItem" onclick="alert('indiana!')">Indiana Jones</div>
</div>
</div>
</div>
</body>
</html>
When you get a class not found in Dojo:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.