AnsweredAssumed Answered

Tried to register widget with id==timeSliderDiv but that id is already registered

Question asked by dmortenson on Feb 11, 2014
Latest reply on Apr 24, 2014 by sarahclark
I have a button that triggers the timeSlider.  It works great.
Then I have a button to clear it - turn off the layer and empty the slider.
When I click the button for the timeSlider again, I get this error:

Tried to register widget with id==timeSliderDiv but that id is already registered

I realize it's trying to initiate the slider again, but I can't seem to properly destroy and redo it on the fly.

functrion wrTime(){
       timeLayer = new FeatureLayer("",
       {mode: esri.layers.FeatureLayer.MODE_ONDEMAND,

      connect.connect(map,'layer-add-result', initSlider());
      function initSlider() {
          var timeSlider = new TimeSlider({
            style: "width: 100%;"
          }, dom.byId("timeSliderDiv"));
          var timeExtent = new TimeExtent();
          timeExtent.startTime = new Date("1/1/1900 UTC");
          timeExtent.endTime = new Date("12/31/2014 UTC");
          timeSlider.createTimeStopsByTimeInterval(timeExtent, 2, "esriTimeUnitsYears");

function clearTime(){      
      // === Turns the theme off ===
      //===== eliminates the element ====
      var element = document.getElementById("timeSliderDiv");
      element.outerHTML = "";
      delete element;

I've tried various versions of destroy,  registry.remove, etc.  Then tried recreating the timeSliderDiv, but I am just not getting it right.

Mostly, I just want it to appear as if it cleared. If you were to show the slider, I don't care if it refreshes or picks up where it left off.  No matter how I slice it, tho, I keep ending up with the same error message.