クラスごとにdijit要素を取得したいと考えています。これらのdocsに基づいて、以下のコードを試しました。私はいくつかのマップ関数のdijit/form/ToggleButtonsをdijit/Toolbarにいくつか持っており、私はトグルを解決しようとしています。 'キャッチされない例外TypeErrorを::dijit.registry.byClassは関数ではありません' 私はthis docs pageいくつかの追加に気づい:クラスごとにdijit要素を取得する
<div class="toolContainer">
<div class="navBarClass" id="navToolbar" data-dojo-type="dijit/Toolbar" data-dojo-props="region:'top'" style="background-color:#ffffff;">
<button type="button" id="zoomin"></button>
<button type="button" id="zoomout"></button>
</div>
</div>
UPDATE
require([
"esri/geometry/Extent",
"esri/toolbars/navigation",
"dojo/on",
"dijit/registry",
"dijit/Toolbar",
"dijit/form/Button",
"dijit/form/ToggleButton"
//"dojo/domReady!"
],
function (Extent, Navigation, on, registry, Toolbar, Button, ToggleButton) {
var navToolbar;
navToolbar = new Navigation(window.myMap);
var zoomInButton = new ToggleButton({
label: "Zoom Avant",
showLabel: false,
iconClass: "zoominIcon",
checked: false,
onClick: function() {
//alert("test button clicked")
navToolbar.activate(Navigation.ZOOM_IN);
toggleButtonIcon(this);
}
}, "zoomin");
zoomInButton.startup();
var zoomOutButton = new ToggleButton({
label: "Zoom Arrière",
showLabel: false,
iconClass: "zoomoutIcon",
onClick: function() {
//alert("test button clicked")
navToolbar.activate(Navigation.ZOOM_OUT);
toggleButtonIcon(this);
}
}, "zoomout");
zoomOutButton.startup();
//this toggles the button highlight in the toolbar to show which tool is currently active
//note - doesn't do the FullExtent since it's a button not a togglebutton
function toggleButtonIcon(tool) {
//only the tools in the toolbar are dijit togglebuttons so can iterate thru them
dijit.registry.byClass("dijit.form.ToggleButton").forEach(function(togbtn) {
if (togbtn == tool) {
togbtn.attr("checked", true);
}
else {
togbtn.attr("checked", false);
}
});
}
});
HTMLの問題は、私が取得しています、です情報が関連している可能性があります。私は今、私の選択肢が何であるかについて混乱しています。私dojo /クエリを使用して探しています。私はクラスに基づいて他のボタンとわずかなボタンを区別できる必要があります。エラーで説明したように
Note that for backwards compatibility, the dijit.registry global variable (as opposed to the dijit/registry module) includes array iterator methods (forEach, filter, byClass, map, every, and some). However, AMD code should not expect these functions to be available in the Object returned from require([“dijit/registry”]).