How to destroy widgets in a dijit Dialog

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to destroy widgets in a dijit Dialog

Harry Devine
I have a Dijit Dialog that I'm putting a FilteringSelect and dGrid in.  When I close it and re-open it, I'm getting the dreaded "tried to register control with id == XXX but that id is already registered" error message.  So I figured I would destroy it when I close the dialog.  But that doesn't work because I can't seem to catch WHERE to catch the dialog closing.  I've tried onClose and onHide but I get nothing.  I even tried to search for the control via "if (registry.byId("controlID") registry.byId("controlID").destroy();", but that doesn't destroy anything.

Any ideas on how I can go about this?

Thanks,
Harry

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: How to destroy widgets in a dijit Dialog

Shahzad3
You can destroy dialog when it's closing, and also can destroy things initiated inside it, once you will destroy dialog , dom related to it and inside it will be automatically deleted, onHide should work, if its not can you share more detail of code, how you are using it, normally it will be like this,

dialog.on('hide',function(){
someDgrid.destroy();
dialog.destroy();
});

Thanks
Shahzad

On Fri, Jul 10, 2015 at 11:53 PM, Harry Devine <[hidden email]> wrote:
I have a Dijit Dialog that I'm putting a FilteringSelect and dGrid in.  When I close it and re-open it, I'm getting the dreaded "tried to register control with id == XXX but that id is already registered" error message.  So I figured I would destroy it when I close the dialog.  But that doesn't work because I can't seem to catch WHERE to catch the dialog closing.  I've tried onClose and onHide but I get nothing.  I even tried to search for the control via "if (registry.byId("controlID") registry.byId("controlID").destroy();", but that doesn't destroy anything.

Any ideas on how I can go about this?

Thanks,
Harry

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: How to destroy widgets in a dijit Dialog

Harry Devine
For some reason, I can NOT destroy that FilteringSelect.  In my main index.php, I declare a <div> as a place holder for the FilteringSelect and the dGrid.  In my javascript file, I create them:

request.post("GetSystemList.php", {
  handleAs: "json",
  method: "POST"
}).then (function(data){


/* Create the Quick Fix System select control */
var systemStore = new Memory({data: data});
if (!registry.byId("quickFixSelect")) {
  var systemSelect = new FilteringSelect({
    id: "systemSelect",
    name: "systemSelect",
    value: "SELECT ONE",
    store: systemStore,
    labelAttr: "system",
    searchAttr: "system",
    style: "width: 200px;"
    }, "quickFixSelect");
  }
  else {
    systemSelect.reset();
    systemSelect.set("store", systemStore);
  }


/* Populate the initial Quick Fix data grid */
request.post("GetQuickFixData.php", {
  handleAs:"json",
  method: "POST"
}).then (function(data) {
  var fixStore = new Memory({data:data});
  var StandardGrid = declare([Grid, Selection, Pagination, ColumnResizer, DijitRegistry]);
  if (!registry.byId("quickFixGrid")) {
    fixGrid = new StandardGrid({
      columns: {
        system: {label: "System", field: "system"},
        problem: {label: "Description of Problem", field: "problem"},
        outcome: {label: "Description of Outcome", field: "outcome"}
    },
    loadingMessage: "Loading Quick Fix results",
    errorMessage: "Error loading Quick Fix results",
    store: fixStore,
    rowsPerPage: 100
    }, "quickFixGrid");
  }
  else {
  console.log("setting store to ", fixStore);
  fixGrid.set("store", fixStore);
}
fixGrid.startup();
});


/* Display the Quick Fix dialog */
registry.byId("QuickFixDlg").show();


In my main page, I handle the hide event and try to destroy the controls as follows:

var dialog=registry.byId("QuickFixDlg");
dialog.on('hide', function() {
  var fixSelect = registry.byId("quickFixSelect");
  var fixGrid = registry.byId("quickGridSelect");

  if (fixSelect) {
    console.log("Destroying Quick Fix select");
    fixSelect.destroy();
  }
  else {
    console.log("fixSelect doesn't exist here");
  }

  if (fixGrid) {
    console.log("Destroying Quick Fix Grid");
    fixGrid.destroy();
  }
  else {
    console.log("fixGrid doesn't exist here");
  }


  dialog.destroy();
});

When I close the dialog, I get "fixSelect doesn't exist here" and "Destroying Quick Fix Grid" in Firebug, implying that the dGrid control is registered and the FilteringSelect control is not.  But is must be or else I wouldn't get the "id is already registered" error the next time I instantiate the dialog.

Any ideas?
Harry

From: "Shahzad Bhatti" <[hidden email]>
To: [hidden email]
Sent: Friday, July 10, 2015 2:59:42 PM
Subject: Re: [Dojo-interest] How to destroy widgets in a dijit Dialog

You can destroy dialog when it's closing, and also can destroy things initiated inside it, once you will destroy dialog , dom related to it and inside it will be automatically deleted, onHide should work, if its not can you share more detail of code, how you are using it, normally it will be like this,

dialog.on('hide',function(){
someDgrid.destroy();
dialog.destroy();
});

Thanks
Shahzad

On Fri, Jul 10, 2015 at 11:53 PM, Harry Devine <[hidden email]> wrote:
I have a Dijit Dialog that I'm putting a FilteringSelect and dGrid in.  When I close it and re-open it, I'm getting the dreaded "tried to register control with id == XXX but that id is already registered" error message.  So I figured I would destroy it when I close the dialog.  But that doesn't work because I can't seem to catch WHERE to catch the dialog closing.  I've tried onClose and onHide but I get nothing.  I even tried to search for the control via "if (registry.byId("controlID") registry.byId("controlID").destroy();", but that doesn't destroy anything.

Any ideas on how I can go about this?

Thanks,
Harry

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: How to destroy widgets in a dijit Dialog

Shahzad3
shouldn't id be systemSelect? as you are hard coding Id for filter select it should be
var fixSelect = registry.byId("systemSelect");

Thanks

On Sat, Jul 11, 2015 at 12:53 AM, Harry Devine <[hidden email]> wrote:
For some reason, I can NOT destroy that FilteringSelect.  In my main index.php, I declare a <div> as a place holder for the FilteringSelect and the dGrid.  In my javascript file, I create them:

request.post("GetSystemList.php", {
  handleAs: "json",
  method: "POST"
}).then (function(data){


/* Create the Quick Fix System select control */
var systemStore = new Memory({data: data});
if (!registry.byId("quickFixSelect")) {
  var systemSelect = new FilteringSelect({
    id: "systemSelect",
    name: "systemSelect",
    value: "SELECT ONE",
    store: systemStore,
    labelAttr: "system",
    searchAttr: "system",
    style: "width: 200px;"
    }, "quickFixSelect");
  }
  else {
    systemSelect.reset();
    systemSelect.set("store", systemStore);
  }


/* Populate the initial Quick Fix data grid */
request.post("GetQuickFixData.php", {
  handleAs:"json",
  method: "POST"
}).then (function(data) {
  var fixStore = new Memory({data:data});
  var StandardGrid = declare([Grid, Selection, Pagination, ColumnResizer, DijitRegistry]);
  if (!registry.byId("quickFixGrid")) {
    fixGrid = new StandardGrid({
      columns: {
        system: {label: "System", field: "system"},
        problem: {label: "Description of Problem", field: "problem"},
        outcome: {label: "Description of Outcome", field: "outcome"}
    },
    loadingMessage: "Loading Quick Fix results",
    errorMessage: "Error loading Quick Fix results",
    store: fixStore,
    rowsPerPage: 100
    }, "quickFixGrid");
  }
  else {
  console.log("setting store to ", fixStore);
  fixGrid.set("store", fixStore);
}
fixGrid.startup();
});


/* Display the Quick Fix dialog */
registry.byId("QuickFixDlg").show();


In my main page, I handle the hide event and try to destroy the controls as follows:

var dialog=registry.byId("QuickFixDlg");
dialog.on('hide', function() {
  var fixSelect = registry.byId("quickFixSelect");
  var fixGrid = registry.byId("quickGridSelect");

  if (fixSelect) {
    console.log("Destroying Quick Fix select");
    fixSelect.destroy();
  }
  else {
    console.log("fixSelect doesn't exist here");
  }

  if (fixGrid) {
    console.log("Destroying Quick Fix Grid");
    fixGrid.destroy();
  }
  else {
    console.log("fixGrid doesn't exist here");
  }


  dialog.destroy();
});

When I close the dialog, I get "fixSelect doesn't exist here" and "Destroying Quick Fix Grid" in Firebug, implying that the dGrid control is registered and the FilteringSelect control is not.  But is must be or else I wouldn't get the "id is already registered" error the next time I instantiate the dialog.

Any ideas?
Harry

From: "Shahzad Bhatti" <[hidden email]>
To: [hidden email]
Sent: Friday, July 10, 2015 2:59:42 PM
Subject: Re: [Dojo-interest] How to destroy widgets in a dijit Dialog


You can destroy dialog when it's closing, and also can destroy things initiated inside it, once you will destroy dialog , dom related to it and inside it will be automatically deleted, onHide should work, if its not can you share more detail of code, how you are using it, normally it will be like this,

dialog.on('hide',function(){
someDgrid.destroy();
dialog.destroy();
});

Thanks
Shahzad

On Fri, Jul 10, 2015 at 11:53 PM, Harry Devine <[hidden email]> wrote:
I have a Dijit Dialog that I'm putting a FilteringSelect and dGrid in.  When I close it and re-open it, I'm getting the dreaded "tried to register control with id == XXX but that id is already registered" error message.  So I figured I would destroy it when I close the dialog.  But that doesn't work because I can't seem to catch WHERE to catch the dialog closing.  I've tried onClose and onHide but I get nothing.  I even tried to search for the control via "if (registry.byId("controlID") registry.byId("controlID").destroy();", but that doesn't destroy anything.

Any ideas on how I can go about this?

Thanks,
Harry

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: How to destroy widgets in a dijit Dialog

Karl Tiedt
The best solution is to not hardwire static ID's in your reusable components.

-Karl Tiedt

On Fri, Jul 10, 2015 at 1:36 PM, Shahzad Bhatti <[hidden email]> wrote:
shouldn't id be systemSelect? as you are hard coding Id for filter select it should be
var fixSelect = registry.byId("systemSelect");

Thanks

On Sat, Jul 11, 2015 at 12:53 AM, Harry Devine <[hidden email]> wrote:
For some reason, I can NOT destroy that FilteringSelect.  In my main index.php, I declare a <div> as a place holder for the FilteringSelect and the dGrid.  In my javascript file, I create them:

request.post("GetSystemList.php", {
  handleAs: "json",
  method: "POST"
}).then (function(data){


/* Create the Quick Fix System select control */
var systemStore = new Memory({data: data});
if (!registry.byId("quickFixSelect")) {
  var systemSelect = new FilteringSelect({
    id: "systemSelect",
    name: "systemSelect",
    value: "SELECT ONE",
    store: systemStore,
    labelAttr: "system",
    searchAttr: "system",
    style: "width: 200px;"
    }, "quickFixSelect");
  }
  else {
    systemSelect.reset();
    systemSelect.set("store", systemStore);
  }


/* Populate the initial Quick Fix data grid */
request.post("GetQuickFixData.php", {
  handleAs:"json",
  method: "POST"
}).then (function(data) {
  var fixStore = new Memory({data:data});
  var StandardGrid = declare([Grid, Selection, Pagination, ColumnResizer, DijitRegistry]);
  if (!registry.byId("quickFixGrid")) {
    fixGrid = new StandardGrid({
      columns: {
        system: {label: "System", field: "system"},
        problem: {label: "Description of Problem", field: "problem"},
        outcome: {label: "Description of Outcome", field: "outcome"}
    },
    loadingMessage: "Loading Quick Fix results",
    errorMessage: "Error loading Quick Fix results",
    store: fixStore,
    rowsPerPage: 100
    }, "quickFixGrid");
  }
  else {
  console.log("setting store to ", fixStore);
  fixGrid.set("store", fixStore);
}
fixGrid.startup();
});


/* Display the Quick Fix dialog */
registry.byId("QuickFixDlg").show();


In my main page, I handle the hide event and try to destroy the controls as follows:

var dialog=registry.byId("QuickFixDlg");
dialog.on('hide', function() {
  var fixSelect = registry.byId("quickFixSelect");
  var fixGrid = registry.byId("quickGridSelect");

  if (fixSelect) {
    console.log("Destroying Quick Fix select");
    fixSelect.destroy();
  }
  else {
    console.log("fixSelect doesn't exist here");
  }

  if (fixGrid) {
    console.log("Destroying Quick Fix Grid");
    fixGrid.destroy();
  }
  else {
    console.log("fixGrid doesn't exist here");
  }


  dialog.destroy();
});

When I close the dialog, I get "fixSelect doesn't exist here" and "Destroying Quick Fix Grid" in Firebug, implying that the dGrid control is registered and the FilteringSelect control is not.  But is must be or else I wouldn't get the "id is already registered" error the next time I instantiate the dialog.

Any ideas?
Harry

From: "Shahzad Bhatti" <[hidden email]>
To: [hidden email]
Sent: Friday, July 10, 2015 2:59:42 PM
Subject: Re: [Dojo-interest] How to destroy widgets in a dijit Dialog


You can destroy dialog when it's closing, and also can destroy things initiated inside it, once you will destroy dialog , dom related to it and inside it will be automatically deleted, onHide should work, if its not can you share more detail of code, how you are using it, normally it will be like this,

dialog.on('hide',function(){
someDgrid.destroy();
dialog.destroy();
});

Thanks
Shahzad

On Fri, Jul 10, 2015 at 11:53 PM, Harry Devine <[hidden email]> wrote:
I have a Dijit Dialog that I'm putting a FilteringSelect and dGrid in.  When I close it and re-open it, I'm getting the dreaded "tried to register control with id == XXX but that id is already registered" error message.  So I figured I would destroy it when I close the dialog.  But that doesn't work because I can't seem to catch WHERE to catch the dialog closing.  I've tried onClose and onHide but I get nothing.  I even tried to search for the control via "if (registry.byId("controlID") registry.byId("controlID").destroy();", but that doesn't destroy anything.

Any ideas on how I can go about this?

Thanks,
Harry

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: How to destroy widgets in a dijit Dialog

Harry Devine
In reply to this post by Shahzad3
Thanks!  That was what the problem ended up being.  I was using the wrong ID.  Working well now.

Thanks!
Harry


From: "Shahzad Bhatti" <[hidden email]>
To: [hidden email]
Sent: Friday, July 10, 2015 4:36:22 PM
Subject: Re: [Dojo-interest] How to destroy widgets in a dijit Dialog

shouldn't id be systemSelect? as you are hard coding Id for filter select it should be
var fixSelect = registry.byId("systemSelect");

Thanks

On Sat, Jul 11, 2015 at 12:53 AM, Harry Devine <[hidden email]> wrote:
For some reason, I can NOT destroy that FilteringSelect.  In my main index.php, I declare a <div> as a place holder for the FilteringSelect and the dGrid.  In my javascript file, I create them:

request.post("GetSystemList.php", {
  handleAs: "json",
  method: "POST"
}).then (function(data){


/* Create the Quick Fix System select control */
var systemStore = new Memory({data: data});
if (!registry.byId("quickFixSelect")) {
  var systemSelect = new FilteringSelect({
    id: "systemSelect",
    name: "systemSelect",
    value: "SELECT ONE",
    store: systemStore,
    labelAttr: "system",
    searchAttr: "system",
    style: "width: 200px;"
    }, "quickFixSelect");
  }
  else {
    systemSelect.reset();
    systemSelect.set("store", systemStore);
  }


/* Populate the initial Quick Fix data grid */
request.post("GetQuickFixData.php", {
  handleAs:"json",
  method: "POST"
}).then (function(data) {
  var fixStore = new Memory({data:data});
  var StandardGrid = declare([Grid, Selection, Pagination, ColumnResizer, DijitRegistry]);
  if (!registry.byId("quickFixGrid")) {
    fixGrid = new StandardGrid({
      columns: {
        system: {label: "System", field: "system"},
        problem: {label: "Description of Problem", field: "problem"},
        outcome: {label: "Description of Outcome", field: "outcome"}
    },
    loadingMessage: "Loading Quick Fix results",
    errorMessage: "Error loading Quick Fix results",
    store: fixStore,
    rowsPerPage: 100
    }, "quickFixGrid");
  }
  else {
  console.log("setting store to ", fixStore);
  fixGrid.set("store", fixStore);
}
fixGrid.startup();
});


/* Display the Quick Fix dialog */
registry.byId("QuickFixDlg").show();


In my main page, I handle the hide event and try to destroy the controls as follows:

var dialog=registry.byId("QuickFixDlg");
dialog.on('hide', function() {
  var fixSelect = registry.byId("quickFixSelect");
  var fixGrid = registry.byId("quickGridSelect");

  if (fixSelect) {
    console.log("Destroying Quick Fix select");
    fixSelect.destroy();
  }
  else {
    console.log("fixSelect doesn't exist here");
  }

  if (fixGrid) {
    console.log("Destroying Quick Fix Grid");
    fixGrid.destroy();
  }
  else {
    console.log("fixGrid doesn't exist here");
  }


  dialog.destroy();
});

When I close the dialog, I get "fixSelect doesn't exist here" and "Destroying Quick Fix Grid" in Firebug, implying that the dGrid control is registered and the FilteringSelect control is not.  But is must be or else I wouldn't get the "id is already registered" error the next time I instantiate the dialog.

Any ideas?
Harry

From: "Shahzad Bhatti" <[hidden email]>
To: [hidden email]
Sent: Friday, July 10, 2015 2:59:42 PM
Subject: Re: [Dojo-interest] How to destroy widgets in a dijit Dialog


You can destroy dialog when it's closing, and also can destroy things initiated inside it, once you will destroy dialog , dom related to it and inside it will be automatically deleted, onHide should work, if its not can you share more detail of code, how you are using it, normally it will be like this,

dialog.on('hide',function(){
someDgrid.destroy();
dialog.destroy();
});

Thanks
Shahzad

On Fri, Jul 10, 2015 at 11:53 PM, Harry Devine <[hidden email]> wrote:
I have a Dijit Dialog that I'm putting a FilteringSelect and dGrid in.  When I close it and re-open it, I'm getting the dreaded "tried to register control with id == XXX but that id is already registered" error message.  So I figured I would destroy it when I close the dialog.  But that doesn't work because I can't seem to catch WHERE to catch the dialog closing.  I've tried onClose and onHide but I get nothing.  I even tried to search for the control via "if (registry.byId("controlID") registry.byId("controlID").destroy();", but that doesn't destroy anything.

Any ideas on how I can go about this?

Thanks,
Harry

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest