<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: .data()</title>
	<atom:link href="http://api.jquery.com/data/feed/" rel="self" type="application/rss+xml" />
	<link>http://api.jquery.com/data/</link>
	<description>jQuery API Reference</description>
	<lastBuildDate>Fri, 19 Mar 2010 22:19:05 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Uli Hecht</title>
		<link>http://api.jquery.com/data/comment-page-1/#comment-1717</link>
		<dc:creator>Uli Hecht</dc:creator>
		<pubDate>Mon, 15 Mar 2010 22:30:10 +0000</pubDate>
		<guid isPermaLink="false">http://api.jquery.com/?p=667#comment-1717</guid>
		<description>&quot;Due to the way browsers interact with plugins and external code, the .data()  method cannot be used on &lt;object&gt;, &lt;applet&gt;  or &lt;embed&gt; elements.&quot;&lt;br&gt;&lt;br&gt;this is even the case for those tags, if being used in xml-files.&lt;br&gt;i think it&#039;s important to mention that because i searched hours for the cause of an issue when i used jQuery to load an xml-file which contains &lt;object&gt;-tags for a different purpose.</description>
		<content:encoded><![CDATA[<p>&#8220;Due to the way browsers interact with plugins and external code, the .data()  method cannot be used on &lt;object&gt;, &lt;applet&gt;  or &lt;embed&gt; elements.&#8221;</p>
<p>this is even the case for those tags, if being used in xml-files.<br />i think it&#39;s important to mention that because i searched hours for the cause of an issue when i used jQuery to load an xml-file which contains &lt;object&gt;-tags for a different purpose.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bob</title>
		<link>http://api.jquery.com/data/comment-page-1/#comment-1631</link>
		<dc:creator>Bob</dc:creator>
		<pubDate>Fri, 12 Mar 2010 16:36:09 +0000</pubDate>
		<guid isPermaLink="false">http://api.jquery.com/?p=667#comment-1631</guid>
		<description>The data function is very good for caching of elements you know you will access later using jQuery. If you store your data on one hidden element with a very simple selector (for example, $(&#039;#myData&#039;).data(&#039;data&#039;)), then the speed gains you will get if you&#039;re using a complicated selector will be very significant. &lt;br&gt;&lt;br&gt;Instead of using the full selector to access a given element every time, you will use that selector only once, store it to the data element (for example, $(&#039;#myData&#039;).data(&#039;myElement&#039;, $(&#039;very-complicated-selector&#039;))), and from then on, if you need to access the element, just do $(&#039;#myData&#039;).data(&#039;myElement&#039;).&lt;br&gt;&lt;br&gt;It&#039;s like using the technique of caching a selector while you use it, except that this will permit caching throughout the life of the script, instead of selecting the element, caching, doing work, then coming back later and selecting the element again.</description>
		<content:encoded><![CDATA[<p>The data function is very good for caching of elements you know you will access later using jQuery. If you store your data on one hidden element with a very simple selector (for example, $(&#39;#myData&#39;).data(&#39;data&#39;)), then the speed gains you will get if you&#39;re using a complicated selector will be very significant. </p>
<p>Instead of using the full selector to access a given element every time, you will use that selector only once, store it to the data element (for example, $(&#39;#myData&#39;).data(&#39;myElement&#39;, $(&#39;very-complicated-selector&#39;))), and from then on, if you need to access the element, just do $(&#39;#myData&#39;).data(&#39;myElement&#39;).</p>
<p>It&#39;s like using the technique of caching a selector while you use it, except that this will permit caching throughout the life of the script, instead of selecting the element, caching, doing work, then coming back later and selecting the element again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: acatalept</title>
		<link>http://api.jquery.com/data/comment-page-1/#comment-1572</link>
		<dc:creator>acatalept</dc:creator>
		<pubDate>Wed, 10 Mar 2010 13:02:45 +0000</pubDate>
		<guid isPermaLink="false">http://api.jquery.com/?p=667#comment-1572</guid>
		<description>It&#039;s not obvious from the documentation, but it appears you can store a function (or a reference to a function) using a .data() call:&lt;br&gt;&lt;br&gt;// store anonymous function in .data()&lt;br&gt;$(&#039;#el&#039;).data(&#039;myFunc&#039;, function(text){ alert(text); });&lt;br&gt;// alert the string &quot;Hello!&quot;&lt;br&gt;$(&#039;#el&#039;).data(&#039;myFunc&#039;)(&#039;Hello!&#039;);&lt;br&gt;&lt;br&gt;Are there any drawbacks to doing this?&lt;br&gt;&lt;br&gt;I&#039;m no javascript expert, and I&#039;m still not real clear on where jQuery is keeping this data, and how well it cleans up after itself.  My concern is primarily if I&#039;m creating and destroying a number of DOM elements on the fly, and attaching functions for use with these temporary elements, will there be any performance issues versus, say, referencing a more permanent function:&lt;br&gt;&lt;br&gt;// define permanent function&lt;br&gt;window.namedFunc = function(text){ alert(text); };&lt;br&gt;// reference permanent function within .data()&lt;br&gt;$(&#039;#el&#039;).data(&#039;myFunc&#039;, namedFunc);&lt;br&gt;// alert the string &quot;Hello!&quot;&lt;br&gt;$(&#039;#el&#039;).data(&#039;myFunc&#039;)(&#039;Hello!&#039;);</description>
		<content:encoded><![CDATA[<p>It&#39;s not obvious from the documentation, but it appears you can store a function (or a reference to a function) using a .data() call:</p>
<p>// store anonymous function in .data()<br />$(&#39;#el&#39;).data(&#39;myFunc&#39;, function(text){ alert(text); });<br />// alert the string &#8220;Hello!&#8221;<br />$(&#39;#el&#39;).data(&#39;myFunc&#39;)(&#39;Hello!&#39;);</p>
<p>Are there any drawbacks to doing this?</p>
<p>I&#39;m no javascript expert, and I&#39;m still not real clear on where jQuery is keeping this data, and how well it cleans up after itself.  My concern is primarily if I&#39;m creating and destroying a number of DOM elements on the fly, and attaching functions for use with these temporary elements, will there be any performance issues versus, say, referencing a more permanent function:</p>
<p>// define permanent function<br />window.namedFunc = function(text){ alert(text); };<br />// reference permanent function within .data()<br />$(&#39;#el&#39;).data(&#39;myFunc&#39;, namedFunc);<br />// alert the string &#8220;Hello!&#8221;<br />$(&#39;#el&#39;).data(&#39;myFunc&#39;)(&#39;Hello!&#39;);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charlie</title>
		<link>http://api.jquery.com/data/comment-page-1/#comment-1435</link>
		<dc:creator>Charlie</dc:creator>
		<pubDate>Thu, 04 Mar 2010 23:29:54 +0000</pubDate>
		<guid isPermaLink="false">http://api.jquery.com/?p=667#comment-1435</guid>
		<description>I&#039;m curious--where is this data stored on the element? I&#039;d like to know just in case I have to debug something, and need to see the data object using something like Firebug.</description>
		<content:encoded><![CDATA[<p>I&#39;m curious&#8211;where is this data stored on the element? I&#39;d like to know just in case I have to debug something, and need to see the data object using something like Firebug.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
