How to destroy a component by id

2388
2
Jump to solution
08-29-2014 06:46 PM
xiaoyunnsongb
New Contributor III

Hello superiors:

       Now I  have  a question like this:

       I create a component  use :

      var myDialog = new dijit.Dialog({

      id:"myDialog ",

     ...

     });

when I create this dialog second , the  error  prompt that  the id has been registerred。

now I want to destroy the dialog  by id  before I create the dialog again ,how can i do it , thanks very much.

0 Kudos
1 Solution

Accepted Solutions
RiyasDeen
Regular Contributor

Hi xiaoyunn,

You can use this before your create widget call. If a widget with the id is available it'll delete it before creating the widget. Understanding _WidgetBase - The Dojo Toolkit 

if (dojo.byId(id)) { dojo.byId(id).destroyRecursive(false); }

View solution in original post

2 Replies
RiyasDeen
Regular Contributor

Hi xiaoyunn,

You can use this before your create widget call. If a widget with the id is available it'll delete it before creating the widget. Understanding _WidgetBase - The Dojo Toolkit 

if (dojo.byId(id)) { dojo.byId(id).destroyRecursive(false); }

View solution in original post

xiaoyunnsongb
New Contributor III

Dear Mr Riyas Deen:

     Thanks very much ,your answer general right,but maybe change the dojo to dijit like

if (dijit.byId(id)) { dijit.byId(id).destroyRecursive(); }

0 Kudos