Hi,
I have a small application in MVC. In this application users search for an address all results(one or more) will show in a select-able grid. When they select any one from the list a JQuery dialog shows the address demography along with a map that focuses on the address
<script>
.
.
var search = new Search({
map: map,
autoNavigate: true,
maxSuggestions: 1,
autoSelect: true,
autoNavigate: true,
maxResults:1,
value: address
}, "searchdiv");
.
.
</script>
<div id="searchdiv"></div>
The first address shows fine. then users closes the dialog and selects another address as soon as the code hits the var search = new Search
This error popsup on the screen.
0x800a139e - JavaScript runtime error: Tried to register widget with id==searchdiv but that id is already registered
I tried to destroy the search but does not work.
Any suggestion would be appreciated.
Thanks,
Ali,
You need to destroy and re-create a new div to attach the search dijit to. Normally when I want to destroy and re-create a dijit many times I will put the dijit inside another div, like:
<div id="searchcontdiv">
<div id="searchdiv"></div>
</div>
Then I destroy the dijit search.destroy() which normally destroys the searchdiv as well, so I use domConstruct to create a new searchdiv and add it to searchcontdiv and then re-create the search dijit.
Thanks for reply,
In my previous post I was not clear when I said “I tried to destroy the search but does not work.” It works and destroys the search but the map does not focus on the address. I use the search.destroy() inside the Require block.
Where do you the destroy the search?
Cambiz,
I am not sure I understand still. Can you go into detail about your workflow? Why exactly are you re-creating the search dijit. Can you not just hide your dialog instead?