how update dojo and dom codes at arcgis java script 4.20 api?

653
5
07-22-2021 04:32 AM
anjelinaponkerat
Occasional Contributor II

Hi

My Site has many errors after update to 4.20, I know 4.2 version don't use dojo. How  can I update dojo and dom codes at arcgis javascript 4.20 api? I don't know how can I update my code and which part of my codes should change?

for example:

on(dojo.query("#pse_meter"), "change", function () {

 

 

Regards

0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

@anjelinaponkerat  Dojo is not gone, it is just not required. In 4.x you should just use native HTML code to get dom elements.

 

const el = document.getElementById("#pse_meter");
el.addEventListener("change", function () {

 

 

anjelinaponkerat
Occasional Contributor II

Thanks

But I have these Errors:

Uncaught SyntaxError: Unexpected token '<'

 

Uncaught TypeError: BingMapsLayer is not a constructor

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

@anjelinaponkerat There are many code change you have to do if you are updating from 3.x to 4.x.

Sounds like you have some syntax error(s) in your code. Hard to say what.

Here is the doc link for 4.x BingMapsLayer.

https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BingMapsLayer.html#constru...

 

0 Kudos
BenRomlein
Occasional Contributor

If you don't want to re-write the code, you should be able to bring dojo into your project separately from the arcgis api:

https://dojotoolkit.org/download/

Either add the cdn url in a script tag to your index.html, or download the toolkit and link to it from your local copy.

StefanUseldinger
Occasional Contributor

Thanks for the information. How do I know, which dojo version I can use? Is there any recommendation?

0 Kudos