<?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 for Truly Evil</title>
	<atom:link href="http://trulyevil.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://trulyevil.com</link>
	<description>An exploration into frontend development</description>
	<lastBuildDate>Mon, 16 Nov 2009 14:33:43 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on Expanding the jQuery Plugin Development Pattern by Mike</title>
		<link>http://trulyevil.com/2009/05/01/eexpanding-the-jquery-plugin-development-pattern/comment-page-1/#comment-93</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Mon, 16 Nov 2009 14:33:43 +0000</pubDate>
		<guid isPermaLink="false">http://trulyevil.com/?p=10#comment-93</guid>
		<description>Sorry but could you please let me know if this is possible at all or I will have to use some other way to do this. Many thanks in advance.</description>
		<content:encoded><![CDATA[<p>Sorry but could you please let me know if this is possible at all or I will have to use some other way to do this. Many thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Expanding the jQuery Plugin Development Pattern by Mike</title>
		<link>http://trulyevil.com/2009/05/01/eexpanding-the-jquery-plugin-development-pattern/comment-page-1/#comment-85</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Mon, 09 Nov 2009 22:13:11 +0000</pubDate>
		<guid isPermaLink="false">http://trulyevil.com/?p=10#comment-85</guid>
		<description>Great, I think we are almost there. So, my question is now: how can I call the getTrue function from outside of the plugin which needs the DOM object to be passed to the function. In other words what would I need to put inside $(&#039;BODY&#039;).myPlugin().getTrue( ??? ); 
I cant thank you enough for putting up with me.</description>
		<content:encoded><![CDATA[<p>Great, I think we are almost there. So, my question is now: how can I call the getTrue function from outside of the plugin which needs the DOM object to be passed to the function. In other words what would I need to put inside $(&#8217;BODY&#8217;).myPlugin().getTrue( ??? );<br />
I cant thank you enough for putting up with me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Expanding the jQuery Plugin Development Pattern by jcfant</title>
		<link>http://trulyevil.com/2009/05/01/eexpanding-the-jquery-plugin-development-pattern/comment-page-1/#comment-84</link>
		<dc:creator>jcfant</dc:creator>
		<pubDate>Mon, 09 Nov 2009 20:15:59 +0000</pubDate>
		<guid isPermaLink="false">http://trulyevil.com/?p=10#comment-84</guid>
		<description>&lt;a href=&quot;#comment-83&quot; rel=&quot;nofollow&quot;&gt;@Mike&lt;/a&gt; 

Hopefully I understand you correctly:

&lt;pre lang=&quot;javascript&quot; line=&quot;1&quot;&gt;

$.fn.testPlugin = function() {
    var self = this;

    this.getTrue = function(item) {
        console.log(&quot;TRUE &quot;, item, $(item));
        return true;
    };
 
    var getFalse = function(item) {
        console.log(&quot;FALSE: &quot;, item, $(item));
        return false;
    };
    this.each( function() {
        console.log(this);
        self.getTrue(this);
        getFalse(this);        
    });

    return this;
};

$(&quot;.content ol:first&quot;).testPlugin();
&lt;/pre&gt;


You can actually run this in firebug on this page and it will produce the following results.

&lt;ol&gt;
TRUE &lt;ol&gt; [ol]
FALSE: &lt;ol&gt; [ol]


Maybe if you pasted some code that isn&#039;t working I could help walk you through it.</description>
		<content:encoded><![CDATA[<p><a href="#comment-83" rel="nofollow">@Mike</a> </p>
<p>Hopefully I understand you correctly:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">testPlugin</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> self <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getTrue</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;TRUE &quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">item</span><span style="color: #339933;">,</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> getFalse <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;FALSE: &quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">item</span><span style="color: #339933;">,</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        self.<span style="color: #660066;">getTrue</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        getFalse<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>        
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.content ol:first&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">testPlugin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>You can actually run this in firebug on this page and it will produce the following results.</p>
<p>&lt;ol&gt;<br />
TRUE &lt;ol&gt; [ol]<br />
FALSE: &lt;ol&gt; [ol]</p>
<p>Maybe if you pasted some code that isn&#8217;t working I could help walk you through it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Expanding the jQuery Plugin Development Pattern by Mike</title>
		<link>http://trulyevil.com/2009/05/01/eexpanding-the-jquery-plugin-development-pattern/comment-page-1/#comment-83</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Mon, 09 Nov 2009 19:50:25 +0000</pubDate>
		<guid isPermaLink="false">http://trulyevil.com/?p=10#comment-83</guid>
		<description>I am really sorry but it seems like I have failed to communicate my problem for 3 times now. How can I potentially do something with $(this) which is the DOM element inside the getTrue or getFalse functions unless I can somehow pass it to them? It would be great if you could give me a sample. Again I am not talking about the jquery object this but the $(this) DOM object inside the this.each{ function() ...
Thanks a lot for all your help</description>
		<content:encoded><![CDATA[<p>I am really sorry but it seems like I have failed to communicate my problem for 3 times now. How can I potentially do something with $(this) which is the DOM element inside the getTrue or getFalse functions unless I can somehow pass it to them? It would be great if you could give me a sample. Again I am not talking about the jquery object this but the $(this) DOM object inside the this.each{ function() &#8230;<br />
Thanks a lot for all your help</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Expanding the jQuery Plugin Development Pattern by jcfant</title>
		<link>http://trulyevil.com/2009/05/01/eexpanding-the-jquery-plugin-development-pattern/comment-page-1/#comment-82</link>
		<dc:creator>jcfant</dc:creator>
		<pubDate>Mon, 09 Nov 2009 19:28:21 +0000</pubDate>
		<guid isPermaLink="false">http://trulyevil.com/?p=10#comment-82</guid>
		<description>&lt;a href=&quot;#comment-81&quot; rel=&quot;nofollow&quot;&gt;@Mike&lt;/a&gt; 
Inside of getFalse you would have to use &quot;self&quot; to access &quot;this&quot;. inside of getTrue, yes you should be able to access &quot;this&quot;.</description>
		<content:encoded><![CDATA[<p><a href="#comment-81" rel="nofollow">@Mike</a><br />
Inside of getFalse you would have to use &#8220;self&#8221; to access &#8220;this&#8221;. inside of getTrue, yes you should be able to access &#8220;this&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Expanding the jQuery Plugin Development Pattern by Mike</title>
		<link>http://trulyevil.com/2009/05/01/eexpanding-the-jquery-plugin-development-pattern/comment-page-1/#comment-81</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Mon, 09 Nov 2009 19:19:33 +0000</pubDate>
		<guid isPermaLink="false">http://trulyevil.com/?p=10#comment-81</guid>
		<description>Thanks again for your prompt response. Let me ask it this way is there any way that I can access $(this) inside this.each( function() { ... inside the getTrue or getFalse functions that you have defined.</description>
		<content:encoded><![CDATA[<p>Thanks again for your prompt response. Let me ask it this way is there any way that I can access $(this) inside this.each( function() { &#8230; inside the getTrue or getFalse functions that you have defined.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Expanding the jQuery Plugin Development Pattern by jcfant</title>
		<link>http://trulyevil.com/2009/05/01/eexpanding-the-jquery-plugin-development-pattern/comment-page-1/#comment-80</link>
		<dc:creator>jcfant</dc:creator>
		<pubDate>Fri, 06 Nov 2009 17:14:44 +0000</pubDate>
		<guid isPermaLink="false">http://trulyevil.com/?p=10#comment-80</guid>
		<description>&lt;a href=&quot;#comment-79&quot; rel=&quot;nofollow&quot;&gt;@Mike&lt;/a&gt; 

It truly depends on how you scope your functions.

&lt;pre lang=&quot;javascript&quot; line=&quot;1&quot;&gt;
$.fn.myPlugin = function(opts){
  var self = this;
  self.opts = $.extend({}, $.fn.myPlugin.defaults, opts);

  this.getTrue = function() {
    return true;
  };

  var getFalse = function() {
    return false;
  };

  return this.each( function() {
     var something = self.opts.something;
     console.log(something);
     console.log(self.getTrue()); // returns true;
     console.log(getFalse()); // returns false;
  }
};
&lt;/pre&gt;

notice the two different ways of creating functions. One is able to be accessed from any reference to the plugin and one is scoped to be hidden.

&lt;pre lang=&quot;javascript&quot; line=&quot;1&quot;&gt;
   $(&#039;BODY&#039;).myPlugin().getTrue(); // returns true;
   $(&#039;BODY&#039;).myPlugin().getFalse(); // fails
&lt;/pre&gt;

Because getFalse is scoped to only be available inside of the function you cannot call it from any where other than in your plugin.

From another plugin you could then access getTrue() but not getFalse.

Hope this helps.</description>
		<content:encoded><![CDATA[<p><a href="#comment-79" rel="nofollow">@Mike</a> </p>
<p>It truly depends on how you scope your functions.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">myPlugin</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>opts<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> self <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
  self.<span style="color: #660066;">opts</span> <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">myPlugin</span>.<span style="color: #660066;">defaults</span><span style="color: #339933;">,</span> opts<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getTrue</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> getFalse <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #003366; font-weight: bold;">var</span> something <span style="color: #339933;">=</span> self.<span style="color: #660066;">opts</span>.<span style="color: #660066;">something</span><span style="color: #339933;">;</span>
     console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>something<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>self.<span style="color: #660066;">getTrue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns true;</span>
     console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>getFalse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns false;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>notice the two different ways of creating functions. One is able to be accessed from any reference to the plugin and one is scoped to be hidden.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'BODY'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">myPlugin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTrue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns true;</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'BODY'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">myPlugin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getFalse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// fails</span></pre></td></tr></table></div>

<p>Because getFalse is scoped to only be available inside of the function you cannot call it from any where other than in your plugin.</p>
<p>From another plugin you could then access getTrue() but not getFalse.</p>
<p>Hope this helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Expanding the jQuery Plugin Development Pattern by Mike</title>
		<link>http://trulyevil.com/2009/05/01/eexpanding-the-jquery-plugin-development-pattern/comment-page-1/#comment-79</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Fri, 06 Nov 2009 17:00:22 +0000</pubDate>
		<guid isPermaLink="false">http://trulyevil.com/?p=10#comment-79</guid>
		<description>Thanks JC. This would solve my problem for variables. But is there anyway that I can trigger a function inside return this.each( function () {. Basically I have a plugin working on a DOM element but I want to be able to change its behavior based on a behavior of another DOM variable (from within another jquery plugin). I am wondering if I have to update my variables and reset this plugin or can I somehow call the functions within plugin from another plugin.</description>
		<content:encoded><![CDATA[<p>Thanks JC. This would solve my problem for variables. But is there anyway that I can trigger a function inside return this.each( function () {. Basically I have a plugin working on a DOM element but I want to be able to change its behavior based on a behavior of another DOM variable (from within another jquery plugin). I am wondering if I have to update my variables and reset this plugin or can I somehow call the functions within plugin from another plugin.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Expanding the jQuery Plugin Development Pattern by jcfant</title>
		<link>http://trulyevil.com/2009/05/01/eexpanding-the-jquery-plugin-development-pattern/comment-page-1/#comment-78</link>
		<dc:creator>jcfant</dc:creator>
		<pubDate>Fri, 06 Nov 2009 15:50:35 +0000</pubDate>
		<guid isPermaLink="false">http://trulyevil.com/?p=10#comment-78</guid>
		<description>Mike, I think the problem lies in how &quot;this&quot; is handled in Javascript.
inside of the following:
&lt;pre lang=&quot;javascript&quot; line=&quot;1&quot;&gt;
return this.each( function() {
    //doing bunch of stuff with $(this)
});
&lt;/pre&gt;

$(this) would refer to the DOM element that the function is called on.

You could access any of the variables inside of $.fn.myPlugin by calling them directly:

&lt;pre lang=&quot;javascript&quot; line=&quot;1&quot;&gt;
   return this.each( function() {
     console.log(opts); // will dump the contents of opts to firebug
    //doing bunch of stuff with $(this)
   });
&lt;/pre&gt;

alternatively you may want setup a variable that you can access from within the each that has the information you need.

&lt;pre lang=&quot;javascript&quot; line=&quot;1&quot;&gt;
 $.fn.myPlugin = function(opts) {
      var self = this;
      self.opts = $.extend({}, $.fn.myPlugin.defaults, opts);
      return this.each( function() {
           // doing bunch of stuff with $(this);
           // if you now need access to opts you can all it like
           var something = self.opts.something;
           console.log(something); // would dump the information to firebug that was set in opts out side of the this.each
      });
&lt;/pre&gt;

Hope that helps.

JC</description>
		<content:encoded><![CDATA[<p>Mike, I think the problem lies in how &#8220;this&#8221; is handled in Javascript.<br />
inside of the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">//doing bunch of stuff with $(this)</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>$(this) would refer to the DOM element that the function is called on.</p>
<p>You could access any of the variables inside of $.fn.myPlugin by calling them directly:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">   <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>opts<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// will dump the contents of opts to firebug</span>
    <span style="color: #006600; font-style: italic;">//doing bunch of stuff with $(this)</span>
   <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>alternatively you may want setup a variable that you can access from within the each that has the information you need.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"> $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">myPlugin</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>opts<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> self <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
      self.<span style="color: #660066;">opts</span> <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">myPlugin</span>.<span style="color: #660066;">defaults</span><span style="color: #339933;">,</span> opts<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           <span style="color: #006600; font-style: italic;">// doing bunch of stuff with $(this);</span>
           <span style="color: #006600; font-style: italic;">// if you now need access to opts you can all it like</span>
           <span style="color: #003366; font-weight: bold;">var</span> something <span style="color: #339933;">=</span> self.<span style="color: #660066;">opts</span>.<span style="color: #660066;">something</span><span style="color: #339933;">;</span>
           console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>something<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// would dump the information to firebug that was set in opts out side of the this.each</span>
      <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Hope that helps.</p>
<p>JC</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Expanding the jQuery Plugin Development Pattern by Mike</title>
		<link>http://trulyevil.com/2009/05/01/eexpanding-the-jquery-plugin-development-pattern/comment-page-1/#comment-77</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Fri, 06 Nov 2009 14:26:24 +0000</pubDate>
		<guid isPermaLink="false">http://trulyevil.com/?p=10#comment-77</guid>
		<description>I am a little confused. I am trying to get access to the variables and functions within this.each( function() { but even after reading all this and trying everything still have a lot of difficulty... 
Any feedback will be greatly appreciated.

(function($){ 

   //bunch of initialization variables and functions
 
   $.fn.myPlugin = function(opts) { 
       opts = $.extend({}, $.fn.myPlugin.defaults, opts);
       return this.each( function() {

          //doing bunch of stuff with $(this)

       });
    };
    $.fn.myPlugin.defaults = {

       // bunch of default options

    };
})(jQuery);





 
});</description>
		<content:encoded><![CDATA[<p>I am a little confused. I am trying to get access to the variables and functions within this.each( function() { but even after reading all this and trying everything still have a lot of difficulty&#8230;<br />
Any feedback will be greatly appreciated.</p>
<p>(function($){ </p>
<p>   //bunch of initialization variables and functions</p>
<p>   $.fn.myPlugin = function(opts) {<br />
       opts = $.extend({}, $.fn.myPlugin.defaults, opts);<br />
       return this.each( function() {</p>
<p>          //doing bunch of stuff with $(this)</p>
<p>       });<br />
    };<br />
    $.fn.myPlugin.defaults = {</p>
<p>       // bunch of default options</p>
<p>    };<br />
})(jQuery);</p>
<p>});</p>
]]></content:encoded>
	</item>
</channel>
</rss>
