Error migrating from 2.2 to 2.3 of the JS API

2137
5
05-23-2011 07:00 AM
ChrisVradis
New Contributor II
Hi,
I have built a web app using the ArcGIS Javascript version 2.2 which works perfectly on Internet Explorer, Firefox, Chrome, Safari and Opera both in Windows XP/Vista and Linux Ubuntu. I have also tested the app with the 2.1 version an still works great.

But when I tried to use the 2.3 version of the JS API I got the following errors from nearly all browsers and both OSs:

Firefox 3.5.17
Error: word is undefined
Code: http://serverapi.arcgisonline.com/jsapi/arcgis/2.3/js/dojo/dijit/dijit.xd.js
Line: 14

Safari:
TypeError: Result of expression 'word' [undefined] is not an object. (dijit.xd.js:14)

Chrome
Uncaught TypeError: Cannot call method 'substring' of undefined (dijit.xd.js:14)

Internet Explorer 9:
SCRIPT5007: Cannot call method 'substring' : object is null or undefined  -
dijit.xd.js, line 14 character 56410
(last message is a rough translation from Greek, as I use the greek version of IE9)

It seems that this has to do with the dojo/dijit library and probably with some difference between version 1.5 and 1.6 ... or not? I can't be sure.

Any help or suggestions would be greatly appreciated...

Thanks in advance
Christoforos
0 Kudos
5 Replies
KellyHutchins
Esri Frequent Contributor
This is due to some changes between earlier versions of dojo and version 1.6.1. Version 2.3 of the ArcGIS API for JavaScript uses version 1.6.1 of dojo and in that version if you have a child of a border container without a region attribute specified you may get the 'word is undefined' error. You can fix this by specifying an region attribute.

http://bugs.dojotoolkit.org/ticket/12795
0 Kudos
ChrisVradis
New Contributor II
Thanks for your prompt reply. Yes, indeed, I had quite a few DIVs with no region attribute, which I fixed, and then after that I got a weird looking and scrambled layout which I suppose will have to re-design.

I have noticed that, in order to get the page shown with no errors, regardless of whether the final appearance is the indented one, the region attribute must be specified even for DIVs that are not always visible such as dijit.Dialog, dijit.Tooltip etc, and (the most frustrating of all) for any DIVs that do not actually participate in the BorderContainer layout creation e.g. are declared with "position: absolute". That can have a significant impact on the entire layout design of a page...

I now understand that this is purely a dojo / dijit issue...In any case, I really wish there was some migration guide that one could read and follow, it would be extremely helpful - and time saving.


This is due to some changes between earlier versions of dojo and version 1.6.1. Version 2.3 of the ArcGIS API for JavaScript uses version 1.6.1 of dojo and in that version if you have a child of a border container without a region attribute specified you may get the 'word is undefined' error. You can fix this by specifying an region attribute.

http://bugs.dojotoolkit.org/ticket/12795
0 Kudos
KellyHutchins
Esri Frequent Contributor
Chris,

I haven't experienced issues with absolutely positioned divs at 1.6. If you'd like to post the code you are having problems with I'd be happy to take a look?
0 Kudos
HemingZhu
Occasional Contributor III
Chris,

I haven't experienced issues with absolutely positioned divs at 1.6. If you'd like to post the code you are having problems with I'd be happy to take a look?


One thing i did to workaround this is to put all the other none region divs within BorderContainer's region ContentPane such as mapGallery in map ContentPane (region="center") etc.
0 Kudos
ChrisVradis
New Contributor II
Thanks for that suggestion, haven't test it yet but it looks like it can actually work, and it sounds like a good layout practice.

What I do in my web app is mix together some DIVs with absolute and relative positioning. The map DIV itself is in the background positioned relatively (but now I've changed that to absolute), and all other DIVs which contain some map controls and other stuff are with "position: absolute". That seemed to be a bit confusing for the 2.3 version...Anyway, what I did to solve it was actually pretty straightforward and fast: I removed all BorderContainers, replaced them with ContentPanes and voila it worked like a charm!

As soon as the web app is complete I will post a URL, as for the time being I cannot post any code...
Thanks again for your suggestions!


One thing i did to workaround this is to put all the other none region divs within BorderContainer's region ContentPane such as mapGallery in map ContentPane (region="center") etc.
0 Kudos