Select to view content in your preferred language

Insert New Layer TOC widget not working

1926
16
Jump to solution
09-12-2014 10:43 AM
AlexGole
Deactivated User

Hi all,

I am trying to understand why the "insert new layer" of the TOC widget does not work with my script. It seems like I hooked the buttons correctly using on(domByID) technic. Not quite sure why the "Insert New Layer of the TOC widget does not work in my script.

Here is my map.

Capture.PNG

TOC widget is here

0 Kudos
16 Replies
RiyasDeen
Frequent Contributor

Hi Alex,

Managed to hook up the events, refer attached (delete.html).

Below is what i have done.

  • Assigned a non-existent class insert-new-layer to the add button (just for accessing the buttons from dojo query)
  • Created a hookClick event with global scope, query elements with class insert-new-layer (you'll get two, one actual element on dom and the other one created by bootstrap) and attaching click event to both.
  • hook global hookClick function to bootstrap on popover show event
AlexGole
Deactivated User

That is quite amazing! It does trigger the "hook click" alert! Should I modify my insert new layer script so that it triggers the "add layer"?

Thanks,

Alex

PS: I am very impressed, thank you again!

0 Kudos
RiyasDeen
Frequent Contributor

Hi Alex,

Glad it helped!

Didn't quite get your question here.

0 Kudos
AlexGole
Deactivated User

Sorry,

In your sample (that works perfectly) I do get the "Hook click" alert in window, but it still does not trigger the  function that allows me to insert a new layer. I cannot figure out why. It must be easy but I don't see what I am missing.

I also get a "Uncaught TypeError: undefined is not a function"

My new map is here.

Thank you for your help and also the great work!

Alex

0 Kudos
JonathanUihlein
Esri Regular Contributor

The order of your dependencies inside the require is wrong. You assign "dojo/query" to "Color" and "dojo/_base/Color" to query. They must match 1 to 1. This is talked about in the introductory documentation.

0 Kudos
RiyasDeen
Frequent Contributor

Hi Alex,

As mentioned by jonathan, the error is coming out because of the wrong module name definition.

You map.addLayer is not scoped within the click event. Move this line

map.addLayer(dynaLayer2);

to before

var h = map.on('layer-add-result', function(evt){

0 Kudos
AlexGole
Deactivated User

Thank you for your help! I will reshape my code.

Alex

0 Kudos