<?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: Sacrificial Lambda</title>
	<atom:link href="http://www.learningjquery.com/2006/09/sacrificial-lambda/feed" rel="self" type="application/rss+xml" />
	<link>http://www.learningjquery.com/2006/09/sacrificial-lambda</link>
	<description>Tips, techniques, and tutorials for the jQuery JavaScript library</description>
	<lastBuildDate>Mon, 15 Mar 2010 11:26:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jonas</title>
		<link>http://www.learningjquery.com/2006/09/sacrificial-lambda/comment-page-1#comment-64020</link>
		<dc:creator>Jonas</dc:creator>
		<pubDate>Mon, 26 Jan 2009 15:12:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2006/09/sacrificial-lambda#comment-64020</guid>
		<description>&lt;strong&gt;Sientz :&lt;/strong&gt;
You could set an id to a div wrapping the &quot;containers&quot; and simplify the hide_function and even integrate the hide and show_function by sending the object the you want to display in the funcion_calling.
&lt;pre&gt;&lt;code&gt;
hide_show_divs = function(d) {
  //HIDE ANY VISIBLE DIVS BEFORE CONTINUING
  $(&quot;#all_contents div&quot;).each(function(){
    if ($(this).is(&#039;:visible&#039;)) {
      $(this).hide(&#039;fast&#039;);
    }
  }
  $(d).show(&#039;fast&#039;);
  return false;  
}
&lt;/code&gt;&lt;/pre&gt;
I&#039;m sure this can be optimized</description>
		<content:encoded><![CDATA[<p><strong>Sientz :</strong><br />
You could set an id to a div wrapping the &#8220;containers&#8221; and simplify the hide_function and even integrate the hide and show_function by sending the object the you want to display in the funcion_calling.</p>
<pre><code>
hide_show_divs = function(d) {
  //HIDE ANY VISIBLE DIVS BEFORE CONTINUING
  $("#all_contents div").each(function(){
    if ($(this).is(':visible')) {
      $(this).hide('fast');
    }
  }
  $(d).show('fast');
  return false;
}
</code></pre>
<p>I&#8217;m sure this can be optimized</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sientz</title>
		<link>http://www.learningjquery.com/2006/09/sacrificial-lambda/comment-page-1#comment-31698</link>
		<dc:creator>Sientz</dc:creator>
		<pubDate>Thu, 21 Feb 2008 06:22:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2006/09/sacrificial-lambda#comment-31698</guid>
		<description>&lt;pre&gt;
&lt;code&gt;
prepare_links = function() {
prepare_links = false; ///!forgotten
&lt;/code&gt;
&lt;/pre&gt;

Do I need to use that =false somewhere in my script?  I have created a div_switch function that hides all my functions at the bottom, where would I insert the div_switch = false; if needed??

&lt;pre&gt;
&lt;code&gt;
$(document).ready(function(){
  
  //THIS HIDES ALL LISTED DIVS ON LOADING OF PAGE
  $(&#039;div.blackbook&#039;).hide();
  $(&#039;div.canvas&#039;).hide();
  $(&#039;div.pencil&#039;).hide();
  $(&#039;div.murals&#039;).hide();
  $(&#039;div.shows&#039;).hide();
  $(&#039;div.tattoos&#039;).hide();
  $(&#039;div.miscellaneous&#039;).hide();
  
  $(&#039;a#blackbook&#039;).click(function() {
    //HIDE DIVS
    hide_divs();
    //SHOW LISTED DIV
    $(&#039;.blackbook&#039;).show(&#039;fast&#039;);
    return false;
  });

  $(&#039;a#canvas&#039;).click(function() {
    //HIDE DIVS
    hide_divs();
    //SHOW LISTED DIV
    $(&#039;.canvas&#039;).show(&#039;fast&#039;);
    return false;
  });    

  $(&#039;a#pencil&#039;).click(function() {
    //HIDE DIVS
    hide_divs();
    //SHOW LISTED DIV
    $(&#039;.pencil&#039;).show(&#039;fast&#039;);
    return false;
  });    

  $(&#039;a#murals&#039;).click(function() {
    //HIDE DIVS
    hide_divs();
    //SHOW LISTED DIV
    $(&#039;.murals&#039;).show(&#039;fast&#039;);
    return false;
  });    

  $(&#039;a#shows&#039;).click(function() {
    //HIDE DIVS
    hide_divs();
    //SHOW LISTED DIV
    $(&#039;.shows&#039;).show(&#039;fast&#039;);
    return false;
  });    

  $(&#039;a#tattoos&#039;).click(function() {
    //HIDE DIVS
    hide_divs();
    //SHOW LISTED DIV
    $(&#039;.tattoos&#039;).show(&#039;fast&#039;);
    return false;
  });    

  $(&#039;a#miscellaneous&#039;).click(function() {
    //HIDE DIVS
    hide_divs();
    //SHOW LISTED DIV
    $(&#039;.miscellaneous&#039;).show(&#039;fast&#039;);
    return false;
  });    

});

//HIDES ANY VISIBLE DIVS

hide_divs = function() {
 
    //HIDE ANY VISIBLE DIVS BEFORE CONTINUING
    if ($(&#039;div.main&#039;).is(&#039;:visible&#039;)) {
    $(&#039;div.main&#039;).hide(&#039;fast&#039;);
    }
    if ($(&#039;div.blackbook&#039;).is(&#039;:visible&#039;)) {
    $(&#039;div.blackbook&#039;).hide(&#039;fast&#039;);
    }    
    if ($(&#039;div.canvas&#039;).is(&#039;:visible&#039;)) {
    $(&#039;div.canvas&#039;).hide(&#039;fast&#039;);
    }
    if ($(&#039;div.pencil&#039;).is(&#039;:visible&#039;)) {
    $(&#039;div.pencil&#039;).hide(&#039;fast&#039;);
    }
    if ($(&#039;div.murals&#039;).is(&#039;:visible&#039;)) {
    $(&#039;div.murals&#039;).hide(&#039;fast&#039;);
    }
    if ($(&#039;div.shows&#039;).is(&#039;:visible&#039;)) {
    $(&#039;div.shows&#039;).hide(&#039;fast&#039;);
    }
    if ($(&#039;div.tattoos&#039;).is(&#039;:visible&#039;)) {
    $(&#039;div.tattoos&#039;).hide(&#039;fast&#039;);
    }
    if ($(&#039;div.miscellaneous&#039;).is(&#039;:visible&#039;)) {
    $(&#039;div.miscellaneous&#039;).hide(&#039;fast&#039;);
    }
}

&lt;/code&gt;
&lt;/pre&gt;

If there is an easier way to do this, please feel free to educate me, I am a rookie at this scripting stuff.</description>
		<content:encoded><![CDATA[<pre>
<code>
prepare_links = function() {
prepare_links = false; ///!forgotten
</code>
</pre>
<p>Do I need to use that =false somewhere in my script?  I have created a div_switch function that hides all my functions at the bottom, where would I insert the div_switch = false; if needed??</p>
<pre>
<code>
$(document).ready(function(){

  //THIS HIDES ALL LISTED DIVS ON LOADING OF PAGE
  $('div.blackbook').hide();
  $('div.canvas').hide();
  $('div.pencil').hide();
  $('div.murals').hide();
  $('div.shows').hide();
  $('div.tattoos').hide();
  $('div.miscellaneous').hide();

  $('a#blackbook').click(function() {
    //HIDE DIVS
    hide_divs();
    //SHOW LISTED DIV
    $('.blackbook').show('fast');
    return false;
  });

  $('a#canvas').click(function() {
    //HIDE DIVS
    hide_divs();
    //SHOW LISTED DIV
    $('.canvas').show('fast');
    return false;
  });    

  $('a#pencil').click(function() {
    //HIDE DIVS
    hide_divs();
    //SHOW LISTED DIV
    $('.pencil').show('fast');
    return false;
  });    

  $('a#murals').click(function() {
    //HIDE DIVS
    hide_divs();
    //SHOW LISTED DIV
    $('.murals').show('fast');
    return false;
  });    

  $('a#shows').click(function() {
    //HIDE DIVS
    hide_divs();
    //SHOW LISTED DIV
    $('.shows').show('fast');
    return false;
  });    

  $('a#tattoos').click(function() {
    //HIDE DIVS
    hide_divs();
    //SHOW LISTED DIV
    $('.tattoos').show('fast');
    return false;
  });    

  $('a#miscellaneous').click(function() {
    //HIDE DIVS
    hide_divs();
    //SHOW LISTED DIV
    $('.miscellaneous').show('fast');
    return false;
  });    

});

//HIDES ANY VISIBLE DIVS

hide_divs = function() {

    //HIDE ANY VISIBLE DIVS BEFORE CONTINUING
    if ($('div.main').is(':visible')) {
    $('div.main').hide('fast');
    }
    if ($('div.blackbook').is(':visible')) {
    $('div.blackbook').hide('fast');
    }
    if ($('div.canvas').is(':visible')) {
    $('div.canvas').hide('fast');
    }
    if ($('div.pencil').is(':visible')) {
    $('div.pencil').hide('fast');
    }
    if ($('div.murals').is(':visible')) {
    $('div.murals').hide('fast');
    }
    if ($('div.shows').is(':visible')) {
    $('div.shows').hide('fast');
    }
    if ($('div.tattoos').is(':visible')) {
    $('div.tattoos').hide('fast');
    }
    if ($('div.miscellaneous').is(':visible')) {
    $('div.miscellaneous').hide('fast');
    }
}

</code>
</pre>
<p>If there is an easier way to do this, please feel free to educate me, I am a rookie at this scripting stuff.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marat</title>
		<link>http://www.learningjquery.com/2006/09/sacrificial-lambda/comment-page-1#comment-4512</link>
		<dc:creator>Marat</dc:creator>
		<pubDate>Fri, 13 Apr 2007 13:57:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2006/09/sacrificial-lambda#comment-4512</guid>
		<description>You have forgoten next moment. To set the whole construction callback to null. Your example overflows browser buffer.
&lt;code&gt;
prepare_links = function() {
     prepare_links = false; ///!forgoten
&lt;/code&gt;
So, what do you thing about it?</description>
		<content:encoded><![CDATA[<p>You have forgoten next moment. To set the whole construction callback to null. Your example overflows browser buffer.<br />
<code><br />
prepare_links = function() {<br />
     prepare_links = false; ///!forgoten<br />
</code><br />
So, what do you thing about it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jörn</title>
		<link>http://www.learningjquery.com/2006/09/sacrificial-lambda/comment-page-1#comment-8</link>
		<dc:creator>Jörn</dc:creator>
		<pubDate>Mon, 04 Sep 2006 07:53:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2006/09/sacrificial-lambda#comment-8</guid>
		<description>Oops, it can be written even DRYer:

do_load = function() {
  $(’#calendar’).load(this.href, prepare_links);
  return false;
}
prepare_links = function() {
  $(’.previous-month, .next-month’).click(do_load);
}
$(prepare_links);

Heh.</description>
		<content:encoded><![CDATA[<p>Oops, it can be written even DRYer:</p>
<p>do_load = function() {<br />
  $(’#calendar’).load(this.href, prepare_links);<br />
  return false;<br />
}<br />
prepare_links = function() {<br />
  $(’.previous-month, .next-month’).click(do_load);<br />
}<br />
$(prepare_links);</p>
<p>Heh.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jörn</title>
		<link>http://www.learningjquery.com/2006/09/sacrificial-lambda/comment-page-1#comment-5</link>
		<dc:creator>Jörn</dc:creator>
		<pubDate>Sun, 03 Sep 2006 20:37:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2006/09/sacrificial-lambda#comment-5</guid>
		<description>You could take this one step further and make it as DRY (Do not Repeat Yourself) as possible:

[code]
do_load = function() {
   $(&#039;#calendar&#039;).load(this.href, prepare_links);
   return false;
}
prepare_links = function() {
  $(&#039;.previous-month, .next-month&#039;).click(do_load);
}
$(document).ready(function() {
   prepare_links();
});
[/code]

I hope that code is readable...</description>
		<content:encoded><![CDATA[<p>You could take this one step further and make it as DRY (Do not Repeat Yourself) as possible:</p>
<div class="igBar"><span id="lcode-1"><a href="#" onclick="javascript:showPlainTxt('code-1'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-1">
<div class="code" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">do_load = function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#ACAA9A;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp;$<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'#calendar'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">load</span><span style="color:#006600; font-weight:bold;">&#40;</span>this.<span style="">href</span>, prepare_links<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp;return false;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#ACAA9A;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">prepare_links = function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#ACAA9A;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; $<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'.previous-month, .next-month'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">click</span><span style="color:#006600; font-weight:bold;">&#40;</span>do_load<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#ACAA9A;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$<span style="color:#006600; font-weight:bold;">&#40;</span>document<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">ready</span><span style="color:#006600; font-weight:bold;">&#40;</span>function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp;prepare_links<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#ACAA9A;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>I hope that code is readable...</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick Hall</title>
		<link>http://www.learningjquery.com/2006/09/sacrificial-lambda/comment-page-1#comment-3</link>
		<dc:creator>Patrick Hall</dc:creator>
		<pubDate>Sun, 03 Sep 2006 20:03:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2006/09/sacrificial-lambda#comment-3</guid>
		<description>Thanks, I finally stumbled across this technique when I got sick of wrapping all the functions I wanted to run in $(&#039;document&#039;).ready() with function(){} wrappers. This way is much cleaner, it&#039;s nice to see that I&#039;m on the right track with that.

The recursion in prepare_links is also something new to me; I didn&#039;t realize that you could self-refer to a function definition in this way. Neat. Confusing, but neat.

PS this blog is a great idea!</description>
		<content:encoded><![CDATA[<p>Thanks, I finally stumbled across this technique when I got sick of wrapping all the functions I wanted to run in $('document').ready() with function(){} wrappers. This way is much cleaner, it's nice to see that I'm on the right track with that.</p>
<p>The recursion in prepare_links is also something new to me; I didn't realize that you could self-refer to a function definition in this way. Neat. Confusing, but neat.</p>
<p>PS this blog is a great idea!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: karl</title>
		<link>http://www.learningjquery.com/2006/09/sacrificial-lambda/comment-page-1#comment-2</link>
		<dc:creator>karl</dc:creator>
		<pubDate>Sun, 03 Sep 2006 18:07:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2006/09/sacrificial-lambda#comment-2</guid>
		<description>Hey Dan, 
So, a &quot;lambda function&quot; is the same thing as an anonymous function, right?</description>
		<content:encoded><![CDATA[<p>Hey Dan,<br />
So, a "lambda function" is the same thing as an anonymous function, right?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
