<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>李文兵 &#187; javascript dojo dijit widget destructor</title>
	<atom:link href="http://liwenbing.cn/tag/javascript-dojo-dijit-widget-destructor/feed/" rel="self" type="application/rss+xml" />
	<link>http://liwenbing.cn</link>
	<description>世界上最好最美的东西你看不见，也摸不着.......但是能在心里感受到</description>
	<lastBuildDate>Fri, 21 May 2010 00:56:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Dojo widget的析构过程</title>
		<link>http://liwenbing.cn/2009/06/05/dojo-widget-destructor/</link>
		<comments>http://liwenbing.cn/2009/06/05/dojo-widget-destructor/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 11:09:13 +0000</pubDate>
		<dc:creator>liwenbing</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[javascript dojo dijit widget destructor]]></category>

		<guid isPermaLink="false">http://liwenbing.cn/?p=204</guid>
		<description><![CDATA[了解dojo widget（或者说dijit）的析构过程，不仅让你更加了解整个dijit的生命周期，同样也能帮助我们在自己定制化的dijit中如何正确地释放资源。（这里讨论的dojo应该是在0.9或者以上版本的) 下面是dijit的析构过程： destroyRecursive / \ destroy destroyDescendants / &#124; \ uninitialize disconnect&#40;&#41; destroyRendering 一些常见的错误是如下： 使用destroy()去销毁一个dijit。我们应该使用destroyRecursive()去销毁一个dijit，从上面的过程可以看出，destroyRecursive()会销毁其孩子widgets。 使用destory()去销毁定制dijit中的资源。更可怕的是有的代码可能是直接覆盖destroy，而根本不调用_Widget中的destory。uninitialize()才是dijit暴露出来给定制化widget进行析构的stub function。 结论 使用destroyRecursive()去销毁dijit，使用uninitialize()在定制化的dijit来释放自己的资源。destroyDescendants，destroyRendering基本上用不到，也不要去覆盖它们。]]></description>
			<content:encoded><![CDATA[<p>了解dojo widget（或者说dijit）的析构过程，不仅让你更加了解整个dijit的生命周期，同样也能帮助我们在自己定制化的dijit中如何正确地释放资源。（这里讨论的dojo应该是在0.9或者以上版本的)</p>
<p>下面是dijit的析构过程：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">                        destroyRecursive
                    <span style="color: #339933;">/</span>                      \
                destroy                   destroyDescendants
        <span style="color: #339933;">/</span>        <span style="color: #339933;">|</span>        \
uninitialize  disconnect<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> destroyRendering</pre></div></div>

<p>一些常见的<strong>错误</strong>是如下：</p>
<ul>
<li>使用destroy()去销毁一个dijit。我们应该使用destroyRecursive()去销毁一个dijit，从上面的过程可以看出，destroyRecursive()会销毁其孩子widgets。</li>
<li>使用destory()去销毁定制dijit中的资源。更可怕的是有的代码可能是直接覆盖destroy，而根本不调用_Widget中的destory。uninitialize()才是dijit暴露出来给定制化widget进行析构的stub function。</li>
</ul>
<h3>结论</h3>
<p><strong>使用destroyRecursive()去销毁dijit，使用uninitialize()在定制化的dijit来释放自己的资源</strong>。destroyDescendants，destroyRendering基本上用不到，也不要去覆盖它们。</p>
]]></content:encoded>
			<wfw:commentRss>http://liwenbing.cn/2009/06/05/dojo-widget-destructor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
