<?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: jQuery Plugin Design Patterns: Part I</title>
	<atom:link href="http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/feed/" rel="self" type="application/rss+xml" />
	<link>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/</link>
	<description></description>
	<lastBuildDate>Wed, 25 Aug 2010 16:03:29 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Bob Spryn</title>
		<link>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/comment-page-1/#comment-2617</link>
		<dc:creator>Bob Spryn</dc:creator>
		<pubDate>Wed, 02 Jun 2010 21:55:43 +0000</pubDate>
		<guid isPermaLink="false">http://fuelyourcoding.com/?p=798#comment-2617</guid>
		<description>Part 2 coming?</description>
		<content:encoded><![CDATA[<p>Part 2 coming?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christoph</title>
		<link>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/comment-page-1/#comment-2127</link>
		<dc:creator>Christoph</dc:creator>
		<pubDate>Wed, 14 Apr 2010 15:09:09 +0000</pubDate>
		<guid isPermaLink="false">http://fuelyourcoding.com/?p=798#comment-2127</guid>
		<description>Looking forward to Part 2!!!</description>
		<content:encoded><![CDATA[<p>Looking forward to Part 2!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kris</title>
		<link>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/comment-page-1/#comment-2052</link>
		<dc:creator>Kris</dc:creator>
		<pubDate>Thu, 01 Apr 2010 13:49:19 +0000</pubDate>
		<guid isPermaLink="false">http://fuelyourcoding.com/?p=798#comment-2052</guid>
		<description>Part &#124;&#124; Please</description>
		<content:encoded><![CDATA[<p>Part || Please</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen</title>
		<link>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/comment-page-1/#comment-1972</link>
		<dc:creator>Stephen</dc:creator>
		<pubDate>Wed, 10 Mar 2010 15:31:04 +0000</pubDate>
		<guid isPermaLink="false">http://fuelyourcoding.com/?p=798#comment-1972</guid>
		<description>Hi, really nice discussion! I&#039;m actually stuck in creating something like the rating widget you described wherein it maintain it&#039;s own data ...is there any chance you can explain further especially how jquery ui is designed to allow something like updating it&#039;s option..  

$(&#039;.selector&#039;).button(&#039;option&#039;, &#039;text&#039;, false);</description>
		<content:encoded><![CDATA[<p>Hi, really nice discussion! I&#8217;m actually stuck in creating something like the rating widget you described wherein it maintain it&#8217;s own data &#8230;is there any chance you can explain further especially how jquery ui is designed to allow something like updating it&#8217;s option..  </p>
<p>$(&#8217;.selector&#8217;).button(&#8217;option&#8217;, &#8216;text&#8217;, false);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: This Weeks Twitter Design News Roundup N.21 - Speckyboy Design Magazine</title>
		<link>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/comment-page-1/#comment-1751</link>
		<dc:creator>This Weeks Twitter Design News Roundup N.21 - Speckyboy Design Magazine</dc:creator>
		<pubDate>Tue, 26 Jan 2010 08:57:55 +0000</pubDate>
		<guid isPermaLink="false">http://fuelyourcoding.com/?p=798#comment-1751</guid>
		<description>[...] jQuery Plugin Design Patterns: Part I [...]</description>
		<content:encoded><![CDATA[<p>[...] jQuery Plugin Design Patterns: Part I [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Linkhub &#8211; Woche 04-2010 &#171; pehbehbeh</title>
		<link>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/comment-page-1/#comment-1740</link>
		<dc:creator>Linkhub &#8211; Woche 04-2010 &#171; pehbehbeh</dc:creator>
		<pubDate>Sun, 24 Jan 2010 16:52:06 +0000</pubDate>
		<guid isPermaLink="false">http://fuelyourcoding.com/?p=798#comment-1740</guid>
		<description>[...] Wie sollten jQuery Plugins aussehen? &#8211; Auf Fuel Your Coding wurde eine Artikelserie zu jQuery Plugins Design Patterns gestartet. [...]</description>
		<content:encoded><![CDATA[<p>[...] Wie sollten jQuery Plugins aussehen? &#8211; Auf Fuel Your Coding wurde eine Artikelserie zu jQuery Plugins Design Patterns gestartet. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sanakan</title>
		<link>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/comment-page-1/#comment-1725</link>
		<dc:creator>sanakan</dc:creator>
		<pubDate>Fri, 22 Jan 2010 18:30:14 +0000</pubDate>
		<guid isPermaLink="false">http://fuelyourcoding.com/?p=798#comment-1725</guid>
		<description>When using Widget Factory, Could I use Mootools(or  Prototype) to creat the Class ,then using jQuery  &quot;data()&quot;  its object ,manipulating  DOM ? I like the OO concept ,also like the jQuery dom magic.</description>
		<content:encoded><![CDATA[<p>When using Widget Factory, Could I use Mootools(or  Prototype) to creat the Class ,then using jQuery  &#8220;data()&#8221;  its object ,manipulating  DOM ? I like the OO concept ,also like the jQuery dom magic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Douglas Neiner</title>
		<link>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/comment-page-1/#comment-1719</link>
		<dc:creator>Douglas Neiner</dc:creator>
		<pubDate>Thu, 21 Jan 2010 17:25:23 +0000</pubDate>
		<guid isPermaLink="false">http://fuelyourcoding.com/?p=798#comment-1719</guid>
		<description>I have favorited that SO article now. I will throw my two cents in when I get a moment :) Thanks for pointing it out!</description>
		<content:encoded><![CDATA[<p>I have favorited that SO article now. I will throw my two cents in when I get a moment :) Thanks for pointing it out!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Douglas Neiner</title>
		<link>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/comment-page-1/#comment-1718</link>
		<dc:creator>Douglas Neiner</dc:creator>
		<pubDate>Thu, 21 Jan 2010 17:23:08 +0000</pubDate>
		<guid isPermaLink="false">http://fuelyourcoding.com/?p=798#comment-1718</guid>
		<description>James, I always appreciate when you stop over and discus our posts here! 

First, you are totally right, it is $.fn.extend. I have updated the post to reflect that.

As far as the &quot;class and function&quot; approach, we haven&#039;t gotten to the true interaction with it yet. However, it is the design pattern employed by jQuery UI for their widgets. If you instantiate a `dialog` for instance, then call `$(&quot;#dialog&quot;).data(&#039;dialog&#039;)` you can retrieve the instance of the Widget class for the dialog. 

A good use case I had for it was a rating system. There were 20 rating widgets, who all maintained their own state independently of the others. However, I also had a ScoreKeeper of sorts that listened for &quot;rating_changed&quot; events on the Rating widgets, and then would access each of the widgets using (through a wrapper) the `data(&#039;RatingWidget&#039;)` and tally up the total. 

This method allows you to build fully independent objects that can interact with each other as needed. By exposing the Class behind the object via `data` you allow your widget to be extended or manipulated by other widgets on the page. Of course you can use standard closures to limit what is available on the object. When `.remove()` is called all the `data` is removed from the element.

Back to jQuery UI, as a final example, when you call `.dialog(&#039;open&#039;)` it is actually finding the instance via `data` then applying the function to that instance behind the scenes. You can check it out starting at line 284 in ui.core.js (1.7.2).</description>
		<content:encoded><![CDATA[<p>James, I always appreciate when you stop over and discus our posts here! </p>
<p>First, you are totally right, it is $.fn.extend. I have updated the post to reflect that.</p>
<p>As far as the &#8220;class and function&#8221; approach, we haven&#8217;t gotten to the true interaction with it yet. However, it is the design pattern employed by jQuery UI for their widgets. If you instantiate a `dialog` for instance, then call `$(&#8221;#dialog&#8221;).data(&#8217;dialog&#8217;)` you can retrieve the instance of the Widget class for the dialog. </p>
<p>A good use case I had for it was a rating system. There were 20 rating widgets, who all maintained their own state independently of the others. However, I also had a ScoreKeeper of sorts that listened for &#8220;rating_changed&#8221; events on the Rating widgets, and then would access each of the widgets using (through a wrapper) the `data(&#8217;RatingWidget&#8217;)` and tally up the total. </p>
<p>This method allows you to build fully independent objects that can interact with each other as needed. By exposing the Class behind the object via `data` you allow your widget to be extended or manipulated by other widgets on the page. Of course you can use standard closures to limit what is available on the object. When `.remove()` is called all the `data` is removed from the element.</p>
<p>Back to jQuery UI, as a final example, when you call `.dialog(&#8217;open&#8217;)` it is actually finding the instance via `data` then applying the function to that instance behind the scenes. You can check it out starting at line 284 in ui.core.js (1.7.2).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Padolsey</title>
		<link>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/comment-page-1/#comment-1717</link>
		<dc:creator>James Padolsey</dc:creator>
		<pubDate>Thu, 21 Jan 2010 16:46:33 +0000</pubDate>
		<guid isPermaLink="false">http://fuelyourcoding.com/?p=798#comment-1717</guid>
		<description>Ah, sorry, that should be:

var instance = new MyClass( $(’#foo’) );</description>
		<content:encoded><![CDATA[<p>Ah, sorry, that should be:</p>
<p>var instance = new MyClass( $(’#foo’) );</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Padolsey</title>
		<link>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/comment-page-1/#comment-1716</link>
		<dc:creator>James Padolsey</dc:creator>
		<pubDate>Thu, 21 Jan 2010 16:46:06 +0000</pubDate>
		<guid isPermaLink="false">http://fuelyourcoding.com/?p=798#comment-1716</guid>
		<description>Nice post Doug!

One thing, shouldn&#039;t it be &quot;jQuery.fn.extend&quot;, not &quot;jQuery.extend&quot; (which extends the jQuery namespace)?

The &quot;class and function&quot; approach is interesting. I&#039;m not too sure I would like having to access a module&#039;s API via data():

$(&#039;#foo&#039;).data(&#039;MyClass&#039;).doSomething(); // doSomething, a method in MyClass&#039; prototype

It just seems wrong. Is this just a solution to a problem that doesn&#039;t exist? If an instance of MyClass needs to be retained (for whatever reason), then I think it would be better to instantiate the class outside of the plugin mechanism and assign the produced instance to a var, like you normally would:

var instance = MyClass( $(&#039;#foo&#039;) );

There was recently an interesting post on StackOverflow that discussed the &quot;limitations&quot; of jQuery&#039;s plugin API, specifically for more complex solutions that require access to an instance: http://stackoverflow.com/questions/2000597/jquery-vs-yahoo-ui-api-design/2000707</description>
		<content:encoded><![CDATA[<p>Nice post Doug!</p>
<p>One thing, shouldn&#8217;t it be &#8220;jQuery.fn.extend&#8221;, not &#8220;jQuery.extend&#8221; (which extends the jQuery namespace)?</p>
<p>The &#8220;class and function&#8221; approach is interesting. I&#8217;m not too sure I would like having to access a module&#8217;s API via data():</p>
<p>$(&#8217;#foo&#8217;).data(&#8217;MyClass&#8217;).doSomething(); // doSomething, a method in MyClass&#8217; prototype</p>
<p>It just seems wrong. Is this just a solution to a problem that doesn&#8217;t exist? If an instance of MyClass needs to be retained (for whatever reason), then I think it would be better to instantiate the class outside of the plugin mechanism and assign the produced instance to a var, like you normally would:</p>
<p>var instance = MyClass( $(&#8217;#foo&#8217;) );</p>
<p>There was recently an interesting post on StackOverflow that discussed the &#8220;limitations&#8221; of jQuery&#8217;s plugin API, specifically for more complex solutions that require access to an instance: <a href="http://stackoverflow.com/questions/2000597/jquery-vs-yahoo-ui-api-design/2000707" rel="nofollow">http://stackoverflow.com/questions/2000597/jquery-vs-yahoo-ui-api-design/2000707</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Tilton</title>
		<link>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/comment-page-1/#comment-1707</link>
		<dc:creator>Josh Tilton</dc:creator>
		<pubDate>Wed, 20 Jan 2010 20:25:00 +0000</pubDate>
		<guid isPermaLink="false">http://fuelyourcoding.com/?p=798#comment-1707</guid>
		<description>Great stuff Doug! As I start to learn more about jQuery, I will be coming here as a resource! Cheers!</description>
		<content:encoded><![CDATA[<p>Great stuff Doug! As I start to learn more about jQuery, I will be coming here as a resource! Cheers!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
