I loop over an array of objects, adding a custom widget to the page each time. I need to put a "space" div atop each widget, and "pageBreak" div at the bottom of each widget. Here is the creation/placement of the widgets inside the loop:
var placeIt = true;
array.forEach(data.features,function(feat,i){
var newDijit = new printDijit({}, domConstruct.create('div'));
newDijit.placeAt(dom.byId('printWindow'));
newDijit.startup();
if (placeIt){
newDijit.cNode(domConstruct.create("div",{class:'space',innerHTML:'a'}));
placeIt = false;
}else{
newDijit.cNode(domConstruct.create("div",{class:'break',innerHTML:'a'}));
placeIt = true;
}
});
Here is the widget:
require([
"dojo/parser",
"dojo/ready",
"dojo/_base/declare",
"dojo/dom-construct",
"dijit/_WidgetBase",
"dijit/_TemplatedMixin",
"dijit/_WidgetsInTemplateMixin"
], function(parser, ready, declare, domConstruct, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin){
declare("printDijit", [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin],{
templateString: dojo.cache(new dojo._Url("printDijit.html")),
cNode: function(htmlCnode){
domConstruct.place(htmlCnode,this.domNode.id,'before');
}
});
});
Here is the widget template; printDijit.html
<div class="printTemplateCls" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline'">
<div class="printHeaderCls" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'">Top-header</div>
<div class="printInputsCls" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'">Top-right pane</div>
<div class="printBottomPaneCls" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="region:'bottom', gutters:false">
<div class="printPicCls" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'leading'" style="width:342px">Bottom-left pane</div>
<div class="printMapCls" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'"></div>
</div>
The html in fireBug looks fine, but the 2nd and onward space/break div's are behind the widget and dont' flow correctly (see screenshot). If the widgets declared everything is good.
Anyone know what's going on here?
had to wrap the template in an outer div, like below. I would assume this is because the original root element was also a widget.
<div>
<div class="printTemplateCls" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline'">
<div class="printHeaderCls" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'">Top-header</div>
<div class="printInputsCls" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'">Top-right pane</div>
<div class="printBottomPaneCls" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="region:'bottom', gutters:false">
<div class="printPicCls" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'leading'" style="width:342px">Bottom-left pane</div>
<div class="printMapCls" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'"></div>
</div>
</div>
Related
I'm using ArcGIS API for Javascript
ArcGIS Javascript
The formatting for the TabContainer is incorrect. However, after I do an "Inspect Element", the formatting corrects itself
Here's the code I use to create TabContainer:
<div id="tab_plot_info" dojoType="dijit/layout/TabContainer" onClick="tabclick" style="width: 100%;"
doLayout="false">
<div id="ploinfoTab" dojoType="dijit/layout/ContentPane" title="Plot Information" selected="true"></div>
<div id="devcodeTab" dojoType="dijit/layout/ContentPane" title="Development Code"></div>
<div id="devcodeprojectTab" dojoType="dijit/layout/ContentPane" title="Development Project"></div>
<div id="onwaniTab" dojoType="dijit/layout/ContentPane" title="Onwnai Address"></div>
<div id="communityfacilityTab" dojoType="dijit/layout/ContentPane" title="Community Facility"></div>
</div>
map.infoWindow.on("show", function () {
registry.byId("tab_plot_info").resize();
});
map.infoWindow.resize(415, 200);
map.infoWindow.setContent(registry.byId("tab_plot_info").domNode);
map.infoWindow.setTitle("Identify Results")
So what's going here and how do I fix the TabContainer formatting? Thanks!
Can you specify/change the scope of a data-dojo-attach-point to something other than the current widget?
eg. I have a templated widget called parent. In that template I have another widget called child1. Nested in child1, I have some widgets. I want to bind these nested widgets to child1 rather than parent.
Edit:
<div data-dojo-type="someContainer" data-dojo-attach-point="parent">
<div data-dojo-type="somePane" data-dojo-attach-point="child1">
<span data-dojo-attach-point="(I want to be bound to somePane)"></span>
</div>
</div>
I'd like to bind the "span" to somePane without having to go through someContainer.
Separate the span into it's own widget and you can add them to the parent like this.
Parent template that contains the content panes
<div style="width: 100%; height: 100%;">
<div data-dojo-type="dijit/layout/LayoutContainer" style="width: 100%; height: 100%" data-dojo-attach-point="mainNode">
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'" >
<div >
<!--some content-->
</div>
</div>
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'" id="center">
<div data-dojo-attach-point="centerNode"></div>
</div>
</div>
</div>
In postCreate method of your parent widget create new instance of the child and attach it to the parent
define([
"dojo/_base/declare",
"dijit/_WidgetBase",
"dijit/_TemplatedMixin",
"dijit/_WidgetsInTemplateMixin",
"dojo/text!./templates/Parent.html",
"somePath/childWidget",
'dojo/domReady!'
], function (
declare,
_WidgetBase,
_TemplatedMixin,
_WidgetsInTemplateMixin,
parentTemplate,
ChildWidget
) {
return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
templateString: parentTemplate,
postCreate: function () {
this.inherited(arguments);
var myChild = new ChildWidget();
myChild.placeAt(this.centerNode);
myChild.startup();
}
});
});
Then because the span is inside it's own widget, you might have a template for it that looks like this
<div>
<span data-dojo-attach-point="spanNode"></span>
</div>
So now the span attach point is decoupled from the parent. You can directly reference the 'spanNode' from within the widget you created for the span.
Declaratively,
in your childWidget that contains the span you can give give it a class name like this
return declare("childWidget", [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], { ...
And in the parent template instead of using an attach point to attach the widget use data-dojo-type like this
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'" id="center">
<div data-dojo-type="childWidget"><!--child widget will get attached here--></div>
</div>
I need to use BorderContainer inside a TabContainer in dojo. My requirement is to have 3 different pane inside each of the tab which I will create. So for that I am trying to use BorderContainer inside TabContainer but it seems to be not working. Here is what I am trying.
A,B and C are the tabs which i am trying to create.Inside which I am using ContentPane for each of them and then BorderContainer to specify left,center and right region for that particular tab.
But it is not giving me any output. Please advise what i am doing wrong here.
<div data-dojo-type="dijit/layout/TabContainer" data-dojo-props="splitter:true, region:'top'">
<div data-dojo-type="dijit/layout/ContentPane" title="A" selected="true" data-dojo-props="splitter:true">
<div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="guuers:false">
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="splitter:true,region:'left'">Left pane of Tab A</div>
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="splitter:true,region:'center'">Center pane of Tab A</div>
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="splitter:true,region:'right'">Right pane of Tab A</div>
</div>
</div>
<div data-dojo-type="dijit/layout/ContentPane" title="B" data-dojo-props="splitter:true">
<div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="guuers:false">
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="splitter:true,region:'left'">Left pane of Tab B</div>
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="splitter:true,region:'center'">Center pane of Tab B</div>
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="splitter:true,region:'right'">Right pane of Tab B</div>
</div>
</div>
<div data-dojo-type="dijit/layout/ContentPane" title="C" selected="true" data-dojo-props="splitter:true">
<div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="guuers:false">
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="splitter:true,region:'left'">Left pane of Tab C</div>
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="splitter:true,region:'center'">Center pane of Tab C</div>
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="splitter:true,region:'right'">Right pane of Tab C</div>
</div>
</div>
</div>
Your declarative markup is correct, but since I can't see the rest of your code I would guess that you are not calling require on TabContainer, BorderContainer and ContentPane. Dojo needs you to bring those in before you can use them declaratively like you are doing. So you would need this in your javascript:
require([
"dojo/parser",
"dijit/layout/BorderContainer",
"dijit/layout/TabContainer",
"dijit/layout/ContentPane"
]);
Here is a pen that shows your code works, so I would check to see if you are pulling in those modules with require.
http://codepen.io/kyledodge/pen/MwpMZm
The other thing to check is if your dojoConfig is set to parseOnLoad:
dojoConfig = {
parseOnLoad: true
};
If not, you'll either need to set that, or require dojo/parser and call parser.parse(). Parser is key to using the data-dojo-type attribute like you are doing. Here is some info that may be helpful:
http://dojotoolkit.org/reference-guide/1.10/dojo/parser.html
I don't exactly have an answer but I think I can pin down exactly why nothing shows up: The border container doesn't seem to "fill" the containing object. I'm trying to put a border container inside another border container, and its child nodes are present but seem to end up with zero height. Apparently you have to explicitly set the border container's dimensions.
Before I implemented a small web interface using dojo 1.5 and with just referencing the paths to the local folders (dojo,dijit,dojox) and using dojo.require to load the modules I wanted, it worked perfectly. Now I upgraded to 1.7 and all of a sudden it does not work even when usin g the url reference. I am referencing one of the demo projects
http://download.dojotoolkit.org/release-1.7.1/dojo-release-1.7.1/dijit/themes/themeTester.html
and was hoping to recreate the page with a few changes. I broke it down to the most simplest form by only having the main menu and it does not appear that way but just as mere text terms below each other.
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Theme Previewer</title>
<script type="text/javascript" dojoConfig="parseOnLoad:false,
async:true"
src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js" > </script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dijit/themes/claro/document.css"/>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dijit/themes/claro/claro.css"/>
<link rel="stylesheet" href="Styles/demo.css"/>
<script type="text/javascript">
var dojoConfig = {
baseUrl: "//ajax.googleapis.com/ajax/libs",
tlmSiblingOfDojo: false,
packages: [
{ name: "dojo", location: "//ajax.googleapis.com/ajax/libs/dojo/1.7.1/" },
{ name: "dijit", location: "//ajax.googleapis.com/ajax/libs/dojo/1.7.1/" },
{ name: "dojox", location: "//ajax.googleapis.com/ajax/libs/dojo/1.7.1/" }
]
};
</script>
<!--script type="text/javascript" src="Scripts/src.js"></script-->
</head>
<body class="claro">
<div id="main" data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'sidebar', gutters:=false">
<div id="header" data-dojo-type="dijit.MenuBar" data-dojo-props="region:'top'">
<div data-dojo-type="dijit.PopupMenuBarItem" id="edit">
<span>Edit</span>
<div data-dojo-type="dijit.Menu" id="editMenu">
<div data-dojo-type="dijit.MenuItem" id="cut" data-dojo-props="
iconClass:'dijitIconCut'
">Cut</div>
<div data-dojo-type="dijit.MenuItem" id="copy" data-dojo-props="
iconClass:'dijitIconCopy'
">Copy</div>
<div data-dojo-type="dijit.MenuItem" id="paste" data-dojo-props="iconClass:'dijitIconPaste'">Paste</div>
<div data-dojo-type="dijit.MenuSeparator" id="separator"></div>
<div data-dojo-type="dijit.MenuItem" id="undo" data-dojo-props="iconClass:'dijitIconUndo'">Undo</div>
</div>
</div>
<div data-dojo-type="dijit.PopupMenuBarItem" id="view">
<span>View</span>
<div data-dojo-type="dijit.Menu" id="viewMenu">
<div data-dojo-type="dijit.MenuItem">Normal</div>
<div data-dojo-type="dijit.MenuItem">Outline</div>
<div data-dojo-type="dijit.PopupMenuItem">
<span>Zoom</span>
<div data-dojo-type="dijit.Menu" id="zoomMenu">
<div data-dojo-type="dijit.MenuItem">50%</div>
<div data-dojo-type="dijit.MenuItem">75%</div>
<div data-dojo-type="dijit.MenuItem">100%</div>
<div data-dojo-type="dijit.MenuItem">150%</div>
<div data-dojo-type="dijit.MenuItem">200%</div>
</div>
</div>
</div>
</div>
<div data-dojo-type="dijit.PopupMenuBarItem" id="themes">
<span>Themes</span>
<div data-dojo-type="dijit.Menu" id="themeMenu"></div>
</div>
<div data-dojo-type="dijit.PopupMenuBarItem" id="dialogs">
<span>Dialogs</span>
<div data-dojo-type="dijit.Menu" id="dialogMenu">
<div data-dojo-type="dijit.MenuItem" data-dojo-props="onClick: showDialog">slow loading</div>
<div data-dojo-type="dijit.MenuItem" data-dojo-props="onClick: showDialogAb">action bar</div>
</div>
</div>
<div data-dojo-type="dijit.PopupMenuBarItem" id="inputPadding">
<span>TextBox Padding</span>
<div data-dojo-type="dijit.Menu" id="inputPaddingMenu">
<div data-dojo-type="dijit.CheckedMenuItem" data-dojo-props="onClick:setTextBoxPadding, checked:true">theme default</div>
<div data-dojo-type="dijit.CheckedMenuItem" data-dojo-props="onClick:setTextBoxPadding">0px</div>
<div data-dojo-type="dijit.CheckedMenuItem" data-dojo-props="onClick:setTextBoxPadding">1px</div>
<div data-dojo-type="dijit.CheckedMenuItem" data-dojo-props="onClick:setTextBoxPadding">2px</div>
<div data-dojo-type="dijit.CheckedMenuItem" data-dojo-props="onClick:setTextBoxPadding">3px</div>
<div data-dojo-type="dijit.CheckedMenuItem" data-dojo-props="onClick:setTextBoxPadding">4px</div>
<div data-dojo-type="dijit.CheckedMenuItem" data-dojo-props="onClick:setTextBoxPadding">5px</div>
</div>
</div>
<div data-dojo-type="dijit.PopupMenuBarItem" id="help">
<span>Help</span>
<div data-dojo-type="dijit.Menu" id="helpMenu">
<div data-dojo-type="dijit.MenuItem">Help Topics</div>
<div data-dojo-type="dijit.MenuItem">About Dijit</div>
</div>
</div>
<div data-dojo-type="dijit.PopupMenuBarItem" data-dojo-props="disabled:true">
<span>Disabled</span>
<div data-dojo-type="dijit.Menu">
<div data-dojo-type="dijit.MenuItem">You should not see this</div>
</div>
</div>
</div>
</div>
I have a separate file that references the items to include:
define([
"dojo/_base/array",
"dojo_base/config",
"dojo/dom",
"dojo/dom-class",
"dojo/dom-construct",
"dojo/_base/kernel",
"dojo/query",
"dojo/ready",
"dojo/_base/window",
"dojo/_base/fx",
"dijit/registry",
"dijit/MenuItem",
"dojo/date/locale",
"dojo/parser",
"dojo/data/ItemFileReadStore",
"dijit/tree/ForestStoreModel",
"dojo/number", //// dojo/number/format
"dojo/dnd/Source",// // dojo/dnd/Source
"dojo/_base/json", //// dojo/toJson
"dojox/grid/DataGrid",
"dojo/data/ItemFileReadStore",
"dojo/parser",
"dijit/form/DateTextBox",
"dojox/widget/AnalogGauge",
"dijit/layout/ContentPane",
"dijit/layout/TabContainer",
"dijit/layout/BorderContainer",
"dijit/layout/AccordionContainer",
"dijit/form/Button",
"dojox/widget/AnalogGauge",
"dojox/widget/gauge/AnalogArcIndicator",
"dojox/widget/gauge/AnalogNeedleIndicator",
"dojox/widget/gauge/AnalogArrowIndicator",
"dijit/MenuBar",
"dijit/PopupMenuBarItem",
"dijit/Menu",
"dijit/MenuItem",
"dijit/Tree",
"dijit/MenuSeparator",
"dijit/Calendar",
"dijit/ColorPalette",
"dijit/dijit-all" // dijit.*
["dojo/dom", "dojo/domReady!"], function(dom){
var greeting = dom.byId("greeting");
greeting.innerHTML += " from Dojo!";
}]);
hope this clarifies it a bit.
The HTML you've pasted specifies 'parseOnLoad: false' when it pulls Dojo in. That'll prevent Dojo from actually parsing any of your data-dojo-type unless you explicitly call parser.parse(). If you change it to 'parseOnLoad: true', does that help? (That's no longer the recommended way to do it, but it would still be useful to try.)
You also seem to have a mixture of Dojo 1.7.2 and 1.7.1 references in the HTML, which is a little odd. Do you need that dojoConfig at all? Dojo ought to be able to find dijit + dojox as siblings of the dojo directory even on the CDN.
But it would definitely help to know what "does not work" actually means: do you get errors, no content appearing?
Later additions to answer:
make sure you're running your files from a web server, not local files, otherwise the XHR requests will fail
get rid of your dojoConfig object: it's not helping
your separate file looks dodgy: you have some strange array bracketing going on
your data-dojo-props on your top div is a bit broken. Write "gutters: 'false'", not "gutters:=false"
Add this in your HTML. It'll load the right modules and kick the parser off manually.
<script>
require(["dojo/parser", "dijit/dijit-all", "dojo/domReady!"], function(parser) {
parser.parse();
});
</script>
That'll get your menu items displaying, although it won't work completely until you add your onClick handler functions.
Finally, make sure you look in your browser console for errors and warnings: that'll provide lots of output that'll help people diagnose future problems. And if you do get problems loading modules, try switching async off because async can sometimes make diagnostics harder.
I am a dojo newb so I am probably making a simple error somewhere. I am trying to get a borderContainer set up without liveSplitters but even though I set it to false the splitters are still there. The gutters:false property is reflected properly Please help me figure out what I am doing wrong.
Thanks
<body class="claro">
<div id="appLayout"
data-dojo-type="dijit.layout.BorderContainer"
data-dojo-props="design: 'headline', gutters: false, liveSplitters: false ">
<div class="centerPanel" data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region: 'center'">
<div>
<h4>Group 1 Content</h4>
<p>para 1</p>
</div>
<div>
<h4>h4 para 2</h4>
</div>
<div>
<h4>h4 para 3</h4>
</div>
</div>
<div class="edgePanel" data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region: 'top'">Header content (top)</div>
<div id="leftCol" class="edgePanel"
data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region: 'left', splitter: true">Sidebar
content (left)</div>
</div>
Remove the splitter attribute from the content pane.
<div id="leftCol" class="edgePanel"
data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region: 'left'>Sidebar
content (left)</div>
The liveSplitters property describes the behavior of the splitters, NOT whether they exist.
// liveSplitters: [const] Boolean
// Specifies whether splitters resize as you drag (true)
// or only upon mouseup (false)
liveSplitters: true,