<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Sacrificial Lambda</title>
	<link>http://www.learningjquery.com/2006/09/sacrificial-lambda</link>
	<description>Getting to know the library of choice for unobtrusive JavaScript</description>
	<pubDate>Fri, 29 Aug 2008 00:00:40 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Sientz</title>
		<link>http://www.learningjquery.com/2006/09/sacrificial-lambda#comment-31698</link>
		<dc:creator>Sientz</dc:creator>
		<pubDate>Thu, 21 Feb 2008 06:22:49 +0000</pubDate>
		<guid>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
  $('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');
    }
}

&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-4512</link>
		<dc:creator>Marat</dc:creator>
		<pubDate>Fri, 13 Apr 2007 13:57:58 +0000</pubDate>
		<guid>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-8</link>
		<dc:creator>Jörn</dc:creator>
		<pubDate>Mon, 04 Sep 2006 07:53:51 +0000</pubDate>
		<guid>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-5</link>
		<dc:creator>Jörn</dc:creator>
		<pubDate>Sun, 03 Sep 2006 20:37:35 +0000</pubDate>
		<guid>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() {
   $('#calendar').load(this.href, prepare_links);
   return false;
}
prepare_links = function() {
  $('.previous-month, .next-month').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">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">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;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&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-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;return false;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">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;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&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-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<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-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&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;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><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-3</link>
		<dc:creator>Patrick Hall</dc:creator>
		<pubDate>Sun, 03 Sep 2006 20:03:55 +0000</pubDate>
		<guid>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 $('document').ready() with function(){} wrappers. This way is much cleaner, it's nice to see that I'm on the right track with that.

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.

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-2</link>
		<dc:creator>karl</dc:creator>
		<pubDate>Sun, 03 Sep 2006 18:07:02 +0000</pubDate>
		<guid>http://www.learningjquery.com/2006/09/sacrificial-lambda#comment-2</guid>
		<description>Hey Dan, 
So, a "lambda function" 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>
