reattach map to different div

665
6
05-01-2014 08:37 AM
JorgeFiallega
New Contributor
Is it possible to reassign the map object to another div on the page ?

      var map = new esri.Map('mapone');


so my map object is created with type esri.Map and attached to the div with id 'mapone'

I would like to do at some point something like this in my code
 
  map.reattach('maptwo');

where 'maptwo' is the id of another div.  (I madeup the reattach method, but something like tis is what I am looking for) so that now my map will show in div 'maptwo'

Thanks
0 Kudos
6 Replies
JonathanUihlein
Esri Regular Contributor
What is your specific use-case? You can always move the dom node itself. I think this would be easier.
0 Kudos
JorgeFiallega
New Contributor
correct.
I oversimplified it a bit. The divs live in two different windows (parent - child windows)
0 Kudos
JonathanUihlein
Esri Regular Contributor
I would move the dom node itself to the second parent. This is the easiest way.
0 Kudos
JorgeFiallega
New Contributor
waoo. That one I dont know how to do.
0 Kudos
JonathanUihlein
Esri Regular Contributor
Vanilla Javascript:

http://jsfiddle.net/Ev8ZH/3/

DOJO Javascript (recommended):

http://dojotoolkit.org/reference-guide/1.9/dojo/dom-construct.html#dojo-dom-construct-place

This should be all you need. Check out DOJO's samples and tutorials if you need any other help.
Make sure you mark this thread as answered if you are satisfied.
Thanks!
0 Kudos
JorgeFiallega
New Contributor
correct, but that is attaching nodes in the dom, within the same DOM tree.
What I dont know how to do is moving things around within two windows.
0 Kudos