Quantcast

Button handler in a dialog being called multiple times

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Button handler in a dialog being called multiple times

Harry Devine

I have a dialog that has a DateTextBox and a TextBox in it.  I take those values, add them to a table in a MySQL database, and hide the dialog.  It works great the first time.  The 2nd time, the handler that I call when I click the Submit button from the dialog gets called twice, resulting in 2 entries being put into the database.  The 3rd time, I get 3 entries, and so on.


How do I hide/close the dialog so that there is only 1 event handler called?  I suspect that the click handler I have keeps getting re-registered every time the dialog is opened, so I suppose my question is how do I ensure that the handler only gets registered once?


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
|  
Report Content as Inappropriate

Re: Button handler in a dialog being called multiple times

Harry Devine

OK, I think I found the solution and wanted to share: in my routine where I initialize the dialog components, I also attach the event handler to the button.  I call on.once instead of just on, and it works as expected.  Sorry for any noise on the list!


Thanks,

Harry

On November 2, 2016 at 7:12 PM Harry Devine <[hidden email]> wrote:

I have a dialog that has a DateTextBox and a TextBox in it.  I take those values, add them to a table in a MySQL database, and hide the dialog.  It works great the first time.  The 2nd time, the handler that I call when I click the Submit button from the dialog gets called twice, resulting in 2 entries being put into the database.  The 3rd time, I get 3 entries, and so on.


How do I hide/close the dialog so that there is only 1 event handler called?  I suspect that the click handler I have keeps getting re-registered every time the dialog is opened, so I suppose my question is how do I ensure that the handler only gets registered once?


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
Loading...