<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>John McCollum &#187; javascript</title>
	<atom:link href="http://johnmc.co/llum/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://johnmc.co/llum</link>
	<description>Muddling through since 1980</description>
	<lastBuildDate>Thu, 02 Sep 2010 21:12:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>A (slightly) better way of working with FireUnit</title>
		<link>http://johnmc.co/llum/a-slightly-better-way-of-working-with-fireunit/</link>
		<comments>http://johnmc.co/llum/a-slightly-better-way-of-working-with-fireunit/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 20:10:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[FireUnit]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=141</guid>
		<description><![CDATA[In &#8216;Anonymous Functions with FireUnit&#8216;, I looked at one quick way of doing some  unit testing within FireUnit. Here&#8217;s a slightly more robust pattern. In a seperate javascript file, you could do something like this: var tests = { &#160;&#160;&#160;&#160;testOk: function(){ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;fireunit.ok(1==1, &#039;This test will pass&#039;); &#160;&#160;&#160;&#160;}, &#160;&#160;&#160;&#160;testCompare: function(){ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;var numChildren = $(&#039;#myDiv&#039;).children(&#039;p&#039;); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;fireunit.compare(numChildren, 4, &#039;#myDiv [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fa-slightly-better-way-of-working-with-fireunit%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fa-slightly-better-way-of-working-with-fireunit%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In &#8216;<a href="http://johnmccollum.co.uk/2010/03/22/anonymous-functons-with-fireunit/">Anonymous Functions with FireUnit</a>&#8216;, I looked at one quick way of doing some  unit testing within FireUnit. Here&#8217;s a slightly more robust pattern. In a seperate javascript file, you could do something like this:</p>
<p><pre><code>
var tests = {
&nbsp;&nbsp;&nbsp;&nbsp;testOk: function(){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fireunit.ok(1==1, &#039;This test will pass&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;},
&nbsp;&nbsp;&nbsp;&nbsp;testCompare: function(){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var numChildren = $(&#039;#myDiv&#039;).children(&#039;p&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fireunit.compare(numChildren, 4, &#039;#myDiv should have 4 child paragraphs&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;}
};

main = function(){
&nbsp;&nbsp;&nbsp;&nbsp;if(typeof fireunit === &#039;object&#039;){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(var test in tests){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tests[test]();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fireunit.testDone();
&nbsp;&nbsp;&nbsp;&nbsp;}
}();

</code></pre></p>
<p>Now, any test functions you add to the tests object will be run when the main function is called (in this case, straight away.)</p>
<p>Simply include this JavaScript file when you want to run your tests, and comment it out or remove it in production.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/a-slightly-better-way-of-working-with-fireunit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery 1.4 Reference Guide &#8211; reviewed</title>
		<link>http://johnmc.co/llum/jquery-1-4-reference-guide-reviewed/</link>
		<comments>http://johnmc.co/llum/jquery-1-4-reference-guide-reviewed/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 19:24:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[book review]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=116</guid>
		<description><![CDATA[Packt Publishing were kind enough to send me a copy of the jQuery 1.4 Reference Guide, by Jonathan Chaffer and Karl Swedberg. The book is intended to be a comprehensive reference for the library, aimed at intermediate to advanced readers. The first point I should make about this book is that it is not intended [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fjquery-1-4-reference-guide-reviewed%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fjquery-1-4-reference-guide-reviewed%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Packt Publishing were kind enough to send me a copy of the <a href="http://www.packtpub.com/jquery-1-4-reference-guide/book">jQuery 1.4 Reference Guide</a>, by Jonathan Chaffer and Karl Swedberg. The book is intended to be a comprehensive reference for the library, aimed at intermediate to advanced readers.</p>
<p>The first point I should make about this book is that it is not intended for users who are new to the jQuery library &#8211; this is not a book full of tutorials. If that&#8217;s what you&#8217;re looking for, you should check out <a href="http://www.packtpub.com/learning-jquery-1.3/book">Learning jQuery 1.3</a> instead, by the same authors.</p>
<p>The book is organised into eleven chapters, covering (amongst other things) selectors, DOM traversal and manipulation, events, effects, and AJAX. The whole library is covered (as you would expect from a reference guide).</p>
<p>Each method in the library has its parameters documented. This is surprisingly helpful &#8211; many jQuery methods can be overloaded for various purposes, and this feature of the book is a great help towards learning the possibilities of each method. In fact, one of the take-home points for me was that many methods now support anonymous functions as parameters, offering lots of flexibility.</p>
<p>Next, a bare bones code sample is shown to demonstrate the method. It is followed  by an explanation of the code sample, along with any &#8216;gotchas&#8217; or quirks that you might experience. Multiple examples of code are shown where there might be different ways to use a particular method. The book really is quite exhaustive, and from that point of view offers great value for money.</p>
<p>Although this book works really well as a reference book, the surprise for me was that it didn&#8217;t <em>just </em>work well as a reference book<em>. </em>Reading through the book, I picked up a lot of hints and tips that will almost certainly change how I use jQuery. For example, I realised that my knowledge of selectors was sorely lacking. (Partly this was because I&#8217;d never bothered to learn the CSS3 selectors properly, but jQuery gives me a reason!)</p>
<p>Another excellent chapter for me was the last one, regarding plug in architecture. The structure of this chapter was a little different, basically walking the reader through the process of creating various types of plugin. Like the best technical books, this chapter actually inspired me to put the book down and write some code &#8211; surely a sign that it was doing its job properly!</p>
<p>It&#8217;s worthwhile to note that if you are considering purchasing a copy of this book, Packt will make a contribution to the jQuery project for every copy sold; so in buying this book, you&#8217;ll increase your own knowledge, and you&#8217;ll be directly helping the jQuery project too. For me, that&#8217;s one of the best reasons to buy.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/jquery-1-4-reference-guide-reviewed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Anonymous functons with FireUnit</title>
		<link>http://johnmc.co/llum/anonymous-functons-with-fireunit/</link>
		<comments>http://johnmc.co/llum/anonymous-functons-with-fireunit/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 19:04:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[FireUnit]]></category>
		<category><![CDATA[Unit Test]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=110</guid>
		<description><![CDATA[FireUnit makes it quick and easy to write unit tests in JavaScript, doing something like the following: fireunit.ok(foo==bar, &#039;foo should equal bar&#039;); But what if you need to do something a little more complex than a one liner? You can write and execute an anonymous function, like this: fireunit.ok(function(){ &#160;&#160;&#160;&#160;var myList = $(&#039;ul&#039;); &#160;&#160;&#160;&#160;var originalLen [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fanonymous-functons-with-fireunit%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fanonymous-functons-with-fireunit%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://fireunit.org">FireUnit</a> makes it quick and easy to write unit tests in JavaScript, doing something like the following:<br />
<pre>fireunit.ok(foo==bar, &#039;foo should equal bar&#039;);</pre><br />
But what if you need to do something a little more complex than a one liner? You can write and execute an anonymous function, like this:<br />
<br />
<pre><pre>fireunit.ok(function(){
&nbsp;&nbsp;&nbsp;&nbsp;var myList = $(&#039;ul&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;var originalLen = myList.children(&#039;li&#039;).length;
&nbsp;&nbsp;&nbsp;&nbsp;fireunit.click( myList );
&nbsp;&nbsp;&nbsp;&nbsp;return $(myList).children() == originalLen + 1;
}(), &#039;This test should return true&#039;);</pre></pre><br />
Two things to note here:</p>
<ol>
<li>Make sure that you include the extra parentheses after the function definition; this executes the function straight away</li>
<li>Make sure you  return true or false  from the function (or an expression that evaluates to true or false.)</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/anonymous-functons-with-fireunit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dan Wellman&#8217;s jQuery UI 1.7 reviewed</title>
		<link>http://johnmc.co/llum/dan-wellmans-jquery-ui-1-7-reviewed/</link>
		<comments>http://johnmc.co/llum/dan-wellmans-jquery-ui-1-7-reviewed/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 20:27:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[book review]]></category>
		<category><![CDATA[jQuery UI]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=98</guid>
		<description><![CDATA[I recently finished reading Dan Wellman&#8216;s book, jQuery UI 1.7 &#8211; The User Interface Library for jQuery. But with the imminent realease of version 1.8 of the popular interface library, is this book still relevant? In my opinion,  it is. This book is recommended for beginner to intermediate users of jQuery UI, and it hits the mark [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fdan-wellmans-jquery-ui-1-7-reviewed%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fdan-wellmans-jquery-ui-1-7-reviewed%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://johnmccollum.co.uk/wp-content/uploads/2010/03/ui17.png"><img class="alignright size-full wp-image-105" title="ui17" src="http://johnmccollum.co.uk/wp-content/uploads/2010/03/ui17.png" alt="" width="100" height="123" /></a>I recently finished reading <a href="http://www.danwellman.co.uk/">Dan Wellman</a>&#8216;s book, <a href="http://www.packtpub.com/user-interface-library-for-jquery-ui-1-7">jQuery UI 1.7 &#8211; The User Interface Library for jQuery</a>. But with the imminent realease of version 1.8 of the popular interface library, is this book still relevant? In my opinion,  it is.</p>
<p>This book is recommended for beginner to intermediate users of jQuery UI, and it hits the mark perfectly for its intended audience. There&#8217;s a chapter for each of the high and low level widgets, as well as the CSS and effects frameworks. Each chapter is structured to follow a logical pattern, and Dan&#8217;s clear writing style means that the code and text is easy to follow.</p>
<p>Each chapter starts with a basic example, and gradually adds more and more options to show the flexibility and power of the framework. The text is supported by numerous code samples, which can be downloaded from <a href="http://www.packtpub.com/">Packt Publishing</a>&#8216;s support site. Finally, each chapter ends with an imaginative, more advanced use of the library. One chapter showcases jQuery UI&#8217;s drag and drop functionality with a game, for example. These examples really bring the code to life, and inspire you to open your favourite text editor and start coding!</p>
<p>The most obvious omission from this book (in fact, the only one worth mentioning, really) is the lack of a section on writing your own plugins for jQuery UI. Dan obviously feels the same way, because he&#8217;s written a <a href="http://net.tutsplus.com/tutorials/javascript-ajax/coding-your-first-jquery-ui-plugin/">tutorial on the subject here</a>, and something like this is promised for the next update of the book. If this more advanced topic is something that interests you, you might want to wait for the next version of the book.</p>
<p>Alternatively, if your knowledge of jQuery UI is at the other end of the spectrum, there&#8217;s no reason at all not to go ahead and buy the current version. The book focuses on the common features of each widget (for example the destroy, enable, and disable methods) so that you can easily adapt to the new components as they appear.</p>
<p>If you&#8217;re somewhere between the two camps, as I was, then this book will consolidate your knowledge and give you lots of inspiration to use the parts of the library you might not have touched on yet. And that, for me, was worth the cover price alone.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/dan-wellmans-jquery-ui-1-7-reviewed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pro Javascript Techniques by John Resig &#8211; a review</title>
		<link>http://johnmc.co/llum/pro-javascript-techniques-by-john-resig-a-review/</link>
		<comments>http://johnmc.co/llum/pro-javascript-techniques-by-john-resig-a-review/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 12:24:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=88</guid>
		<description><![CDATA[I&#8217;ve just finished reading Pro JavaScript Techniques by John Resig, and I thought I&#8217;d post some thoughts about it. The author, John Resig, is the creator of the popular jQuery library. He also works as a Javascript evangelist for Mozilla, so there&#8217;s no doubt that he&#8217;s one of the best known proponents of the language. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fpro-javascript-techniques-by-john-resig-a-review%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fpro-javascript-techniques-by-john-resig-a-review%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><img class="alignright size-full wp-image-89" title="pro-javascript-techniques" src="http://johnmccollum.co.uk/wp-content/uploads/2009/10/pro-javascript-techniques.jpg" alt="pro-javascript-techniques" width="240" height="240" />I&#8217;ve just finished reading <a href="http://www.amazon.com/gp/product/1590597273?ie=UTF8&amp;tag=johnmccollumc-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1590597273">Pro JavaScript Techniques</a> by John Resig, and I thought I&#8217;d post some thoughts about it.</p>
<p>The author, <a href="http://ejohn.org">John Resig</a>, is the creator of the popular <a href="http://jquery.com">jQuery</a> library. He also works as a Javascript evangelist for <a href="http://www.mozilla.org/">Mozilla</a>, so there&#8217;s no doubt that he&#8217;s one of the best known proponents of the language.</p>
<p>Although I use the jQuery library on a daily basis, I was keen to brush up on some of the finer points of Javascript; my knowledge of the jQuery library probably exceeds my knowledge of Javascript! For this reason, I thought the book sounded good.</p>
<p>The first half of the book certainly doesn&#8217;t disappoint. Covering the nitty-gritty of DOM traversal, OO Javascript, and unobtrusive scripting, the book does a great job of covering a lot of ground in a concise, clear manner. The key concepts are illustrated with plenty of code snippets which do a great job of illuminating the subject matter.</p>
<p>The second part of the book was less useful for me, illustrating some examples of AJAX functionality, image galleries, autocomplete, that sort of thing. These topics might have been considered intermediate to advanced in 2006, when the book was released, but the plethora of options around today means that developing stuff like that now is re-inventing the wheel. (Of course you might be interested in <a href="http://www.codinghorror.com/blog/archives/001145.html">learning more about wheels</a>!)</p>
<p>You can almost see the snippets of code in this book forming the nuts and bolts of the jQuery library, and it&#8217;s interesting to take a look at the hoops we developers would have to jump through to otherwise gain cross-browser compliance.</p>
<p>I&#8217;m just glad I&#8217;m not the one having to negotiate those hoops myself!</p>
<p>To sum up, this book is still worth reading for the first half alone, and the stuff on OO javascript, scoping, closures etc is really useful. But some might consider the book a little out of date, so be warned.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/pro-javascript-techniques-by-john-resig-a-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
