Dojo,如何销毁自定义小部件?
我创建了一个自定义 dijit 小部件,其中包含一个网格和一些按钮。
摧毁它的正确方法是什么?重写取消初始化、销毁、销毁递归?哪种方法以及按什么顺序?
谢谢。
I have created a custom dijit widget which contains a grid and some buttons.
What is the right way to destroy it? override uninitialize, destroy, destroyRecursive? which method and in which order?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般来说,
uninitialize
是执行此操作的最佳位置,因为它是在发生其他拆卸之前在destroy
函数中调用的扩展点。也就是说,根据您添加子窗口小部件的方式,您实际上可能不需要执行任何操作。例如,如果您在模板中定义子窗口小部件,则在模板中声明的窗口小部件会自动添加到在
destroy
中迭代的数组中。如果您想确定,为了进行测试,您可以连接到子窗口小部件的
destroy
方法,以便在调用它们时记录一条消息。Generally
uninitialize
is the best place to do this, since it is an extension point called within thedestroy
function before other teardown occurs.That said, depending on how you are adding your child widgets, you may not actually have to do anything. For instance, if you are defining your child widgets within a template, widgets declared within a template automatically get added to an array which is iterated through in
destroy
.If you wanted to be sure, for testing you could connect to the
destroy
methods of your child widgets to log a message when they get called.