<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Pure-Essence.Net &#187; javascript</title>
	<atom:link href="http://pure-essence.net/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://pure-essence.net</link>
	<description>You have to visit this geeky girl&#039;s blog.</description>
	<lastBuildDate>Wed, 23 May 2012 01:27:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='pure-essence.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Pure-Essence.Net &#187; javascript</title>
		<link>http://pure-essence.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://pure-essence.net/osd.xml" title="Pure-Essence.Net" />
	<atom:link rel='hub' href='http://pure-essence.net/?pushpress=hub'/>
		<item>
		<title>jQuery.each vs Javascript for loop</title>
		<link>http://pure-essence.net/2011/09/02/jquery-each-vs-javascript-for-loop/</link>
		<comments>http://pure-essence.net/2011/09/02/jquery-each-vs-javascript-for-loop/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 21:31:15 +0000</pubDate>
		<dc:creator>pureessence</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[for loop]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://pure-essence.net/?p=2164</guid>
		<description><![CDATA[Being a big jQuery fan, I use jQuery.each method a lot in my Javascript code. Until recently I didn&#8217;t think too hard what jQuery.each really is. Its description says it&#8217;s an iterator but it certainly is NOT a true iterator. For example: Let me know what you expect the code below to return. Before I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&#038;blog=23194870&#038;post=2164&#038;subd=pe20110517&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Being a big jQuery fan, I use jQuery.each method a lot in my Javascript code. Until recently I didn&#8217;t think too hard what jQuery.each really is.</p>
<p><a href="http://api.jquery.com/jQuery.each/">Its description</a> says it&#8217;s an iterator but it certainly is NOT a true iterator.</p>
<p>For example:</p>
<p>Let me know what you expect the code below to return.</p>
<p><pre class="brush: jscript; wrap-lines: false;">
var myVars = ['foo1', 'foo2', 'foo3'];

function containsValue(myValue, myCollection) {
	jQuery.each(myCollection, function(i, val) {
		if(val == myValue) {
			return true;
		}
	});
	return false;
}

$(document).ready(function() {
	console.log(containsValue('foo2', myVars));
});
</pre></p>
<p>Before I know better, I&#8217;d expect it to return true. Since myCollection DOES CONTAIN the value &#8216;foo2&#8242;. However the function <b>containsValue WILL ALWAYS RETURN FALSE</b>. That&#8217;s because when you return out of jQuery.each, it simply exits out of jQuery.each but not the containing function. In fact, whether you do anything in the callback function at all, jQuery.each ALWAYS RETURNS the collection you pass in.</p>
<p>e.g.<br />
<pre class="brush: jscript; wrap-lines: false;">
var returnedVar = jQuery.each(myVars, function(i, val) {});
console.log(returnedVar === myVars); // evaluates to true
</pre></p>
<p>In my opinion, jQuery.each acts more like a closure than an iterator. Sure you may use it as an iterator as long as you not returning anything. If you are just changing behaviors or collecting information, it will mimic an iterator. But you need to know, it really is not an iterator.</p>
<p>Personally I&#8217;m going to start to use <a href="http://www.w3schools.com/js/js_loop_for_in.asp" target="_blank">Javascript&#8217;s native for..in statement</a> instead of jQuery.each for Javascript collection variables. There is also an argument that jQuery.each may never perform faster than the native support for an iterator. Therefore below I will rewrite the function above using for..in.</p>
<p><pre class="brush: jscript; wrap-lines: false;">
function containsValueWithFor(myValue, myCollection) {
	for (index in myCollection) {
		if(myCollection[index] == myValue) {
			return true;
		}
	}
	return false;
}

console.log(containsValueWithFor('foo2', myVars)); // true

var myMap = {'lala':'foo1', '2':'foo2', 'b':'foo3'};

console.log(containsValueWithFor('foo2', myMap)); // true as well for an object/map
</pre></p>
<p><b>&#8212;&gt;<a href="http://regretless.com/stuff/jQuery/jQueryEach.html" target="_blank">Example code</a>&lt;&#8212;</b></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pe20110517.wordpress.com/2164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pe20110517.wordpress.com/2164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pe20110517.wordpress.com/2164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pe20110517.wordpress.com/2164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pe20110517.wordpress.com/2164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pe20110517.wordpress.com/2164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pe20110517.wordpress.com/2164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pe20110517.wordpress.com/2164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pe20110517.wordpress.com/2164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pe20110517.wordpress.com/2164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pe20110517.wordpress.com/2164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pe20110517.wordpress.com/2164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pe20110517.wordpress.com/2164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pe20110517.wordpress.com/2164/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&#038;blog=23194870&#038;post=2164&#038;subd=pe20110517&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pure-essence.net/2011/09/02/jquery-each-vs-javascript-for-loop/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fcfd5e14ca9c91790e95dfdb1d2ad756?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pureessence</media:title>
		</media:content>
	</item>
		<item>
		<title>QUnit &#8211; test your javascript</title>
		<link>http://pure-essence.net/2011/07/24/qunit-test-your-javascript/</link>
		<comments>http://pure-essence.net/2011/07/24/qunit-test-your-javascript/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 16:28:06 +0000</pubDate>
		<dc:creator>pureessence</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[non php code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[qunit]]></category>
		<category><![CDATA[unit test]]></category>

		<guid isPermaLink="false">http://pure-essence.net/?p=2139</guid>
		<description><![CDATA[After over ten years of javascript programming, I&#8217;m finally seriously considering writing at least unit tests for my javascript. Since I&#8217;m such a big fan of jQuery, QUnit seems like the obvious choice. It&#8217;s sad but better late than never. The truth is, in my opinion, the fact that javascript test frameworks do not yet [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&#038;blog=23194870&#038;post=2139&#038;subd=pe20110517&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After over ten years of javascript programming, I&#8217;m finally seriously considering writing at least unit tests for my javascript. Since I&#8217;m such a big fan of jQuery, <a href="http://docs.jquery.com/QUnit">QUnit</a> seems like the obvious choice.</p>
<p>It&#8217;s sad but better late than never.</p>
<p>The truth is, in my opinion, the fact that javascript test frameworks do not yet maturely work with many of the continuous integration software deters programmers from using them. What&#8217;s the point of unit testing if they don&#8217;t automatically get run? Based on my research, <a href="http://www.jsunit.net/" target="_blank">JSUnit</a> is the only one that integrates with ANT innately. But JSUnit is more of an abandomware now so people are looking for alternatives.</p>
<p><strong>QUnit + CI topics</strong></p>
<ul>
<li>
<a href="http://lostechies.com/joshuaflanagan/2008/09/18/running-jquery-qunit-tests-under-continuous-integration/" target="_blank">jQuery tests under CI</a>
</li>
<li>
<a href="http://jupiterjs.com/#news/syn-a-standalone-synthetic-event-library" target="_blank">Syn instead of Selenium?</a>
</li>
<li>
<a href="http://docs.jquery.com/Qunit#Integration_into_Browser_Automation_Tools" target="_blank">QUnit and automated browser tools</a>
</li>
</ul>
<p>&gt;&gt; <a href="http://regretless.com/stuff/qunit/testSuite.html" target="_blank">Run my test suite</a> &lt;&lt;</p>
<p><strong>QUnit simple example:</strong></p>
<p>HTML:<br />
<pre class="brush: xml; wrap-lines: false;">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;Test Suite&lt;/title&gt;
	&lt;script src=&quot;http://code.jquery.com/jquery-latest.js&quot;&gt;&lt;/script&gt;
	&lt;link rel=&quot;stylesheet&quot; href=&quot;http://code.jquery.com/qunit/git/qunit.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/qunit/git/qunit.js&quot;&gt;&lt;/script&gt;
	&lt;!-- Your source files go here --&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;functions.js&quot;&gt;&lt;/script&gt;

	&lt;!-- Your tests files go here --&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;isEvenTest.js&quot;&gt;&lt;/script&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;startsWithTest.js&quot;&gt;&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
	&lt;h1 id=&quot;qunit-header&quot;&gt;QUnit example&lt;/h1&gt;
	&lt;h2 id=&quot;qunit-banner&quot;&gt;&lt;/h2&gt;
	&lt;div id=&quot;qunit-testrunner-toolbar&quot;&gt;&lt;/div&gt;
	&lt;h2 id=&quot;qunit-userAgent&quot;&gt;&lt;/h2&gt;
	&lt;ol id=&quot;qunit-tests&quot;&gt;&lt;/ol&gt;

	&lt;!-- Any HTML you may require for your tests to work properly --&gt;
	&lt;div id=&quot;qunit-fixture&quot;&gt;test markup, will be hidden&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre></p>
<p>Source javascript file:<br />
<pre class="brush: jscript; wrap-lines: false;">
function isEven(val) {
	return val % 2 === 0;
}

function startsWith(data, startsWithStr) {
	data = jQuery.trim(data);
	startsWithStr = jQuery.trim(startsWithStr);
	if(data) {
		return data.toUpperCase().lastIndexOf(startsWithStr.toUpperCase(), 0) === 0;
	} else if(data === startsWithStr) {
		return true;
	} else {
		return false;
	}
}
</pre></p>
<p>Sample test file:<br />
<pre class="brush: jscript; wrap-lines: false;">
$(document).ready(function(){

	module(&quot;startsWithTest&quot;);

	test('startsWith', function() { 
		ok(startsWith(&quot;ll-925&quot;, &quot;ll-&quot;), 'Starts with ll-'); 
		ok(!startsWith(&quot;ll-925&quot;, &quot;xl-&quot;), 'Does not start with xl-'); 
		ok(!startsWith(&quot;&quot;, &quot;xx-&quot;), 'Does not start with xx-'); 
		ok(startsWith(&quot; xx-sdgj &quot;, &quot;xx-&quot;), 'Trimming test: starts with xx-'); 
		ok(startsWith(&quot; xx-sdgj&quot;, &quot; xx- &quot;), 'Trimming test 2: starts with xx-'); 
		ok(startsWith(&quot;&quot;, &quot; &quot;), 'Empty string starts with empty string'); 
		ok(startsWith(&quot;Mn-u59&quot;, &quot;mN-&quot;), 'Non case sensitive test'); 
//		raises(startsWith(foo, &quot; &quot;), 'Undefined test 1');  // undefined is obviously not considered a normal exception
	}) 

});
</pre></p>
<p>&gt;&gt; <a href="https://github.com/dodozhang21/QUnit-Example" target="_blank">git repo for the source</a> &lt;&lt;</p>
<p><strong>Additional resources:</strong></p>
<ul>
<li><a href="http://net.tutsplus.com/tutorials/javascript-ajax/how-to-test-your-javascript-code-with-qunit/" target="_blank">QUnit tutorials</a></li>
<li><a href="http://docs.jquery.com/QUnit#API_documentation" target="_blank">API documentation</a></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pe20110517.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pe20110517.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pe20110517.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pe20110517.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pe20110517.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pe20110517.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pe20110517.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pe20110517.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pe20110517.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pe20110517.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pe20110517.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pe20110517.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pe20110517.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pe20110517.wordpress.com/2139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&#038;blog=23194870&#038;post=2139&#038;subd=pe20110517&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pure-essence.net/2011/07/24/qunit-test-your-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fcfd5e14ca9c91790e95dfdb1d2ad756?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pureessence</media:title>
		</media:content>
	</item>
		<item>
		<title>Firebug command line</title>
		<link>http://pure-essence.net/2010/01/12/firebug-command-line/</link>
		<comments>http://pure-essence.net/2010/01/12/firebug-command-line/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 23:39:57 +0000</pubDate>
		<dc:creator>pureessence</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://regretless.com/?p=1557</guid>
		<description><![CDATA[If you do any javascript programming at all, you absolutely need to get the firebug plugin for firefox. It&#8217;s by far the best free tool out there. I&#8217;ve had the plugin since it first came out. However, I just learned about its command line feature today when I was reading this peeling away jQuery wrapper [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&#038;blog=23194870&#038;post=1557&#038;subd=pe20110517&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you do any javascript programming at all, you absolutely need to get <a href="http://getfirebug.com/">the firebug plugin for firefox</a>. It&#8217;s by far the best free tool out there. I&#8217;ve had the plugin since it first came out. However, I just learned about <a href="http://getfirebug.com/cl.html">its command line feature</a> today when I was reading <a href="http://www.learningjquery.com/2008/12/peeling-away-the-jquery-wrapper">this peeling away jQuery wrapper post</a>.</p>
<p>How did I miss such any important new feature? Once you can get auto updates for plugins for firefox, you stop visiting the plugin site. So you don&#8217;t really pay attention to all of its new features. I am however extremely happy to learn about it today.</p>
<p><a href="http://getfirebug.com/"><img src="http://regretless.com/stuff/firebug/screenCL-autocomplete.gif" alt="firebug command line" class="blogpic" /></a></p>
<p>jQuery tip: Did you know you could prevent an event from executing more than once by doing<br />
<pre class="brush: jscript; wrap-lines: false;">
$(&quot;#someAnchorId&quot;).one(&quot;click&quot;, function(){
    //implementation
});
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pe20110517.wordpress.com/1557/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pe20110517.wordpress.com/1557/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pe20110517.wordpress.com/1557/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pe20110517.wordpress.com/1557/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pe20110517.wordpress.com/1557/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pe20110517.wordpress.com/1557/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pe20110517.wordpress.com/1557/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pe20110517.wordpress.com/1557/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pe20110517.wordpress.com/1557/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pe20110517.wordpress.com/1557/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pe20110517.wordpress.com/1557/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pe20110517.wordpress.com/1557/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pe20110517.wordpress.com/1557/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pe20110517.wordpress.com/1557/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&#038;blog=23194870&#038;post=1557&#038;subd=pe20110517&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pure-essence.net/2010/01/12/firebug-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fcfd5e14ca9c91790e95dfdb1d2ad756?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pureessence</media:title>
		</media:content>

		<media:content url="http://regretless.com/stuff/firebug/screenCL-autocomplete.gif" medium="image">
			<media:title type="html">firebug command line</media:title>
		</media:content>
	</item>
		<item>
		<title>Javascript Error: submit is not a function</title>
		<link>http://pure-essence.net/2008/10/15/javascript-error-submit-is-not-a-function/</link>
		<comments>http://pure-essence.net/2008/10/15/javascript-error-submit-is-not-a-function/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 18:13:35 +0000</pubDate>
		<dc:creator>pureessence</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[non php code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[javascript error]]></category>
		<category><![CDATA[submit is not a function]]></category>

		<guid isPermaLink="false">http://regretless.com/?p=1333</guid>
		<description><![CDATA[Just my luck and I ran into the dreaded submit is not a function javascript error. Here&#8217;s the scenario. While coding javascript along, you get a form via id or name on your html page and calls the submit() function on it. You think it should just behave as expected (submits the form) instead nothing [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&#038;blog=23194870&#038;post=1333&#038;subd=pe20110517&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just my luck and I ran into the dreaded submit is not a function javascript error.</p>
<p>Here&#8217;s the scenario.</p>
<p>While coding javascript along, you get a form via id or name on your html page and calls the submit() function on it. You think it should just behave as expected (submits the form) instead nothing happens and in firebug, you get a submit is not a function error. You are like WTF is going on? You start to wonder if you remembered the syntax correctly so you do some research and all the pages tell you yes it&#8217;s just submit() and nothing else.</p>
<p>Finally you start to search on the error &#8220;submit is not a function&#8221; you get to <a href="http://www.chovy.com/javascript/javascript-error-submit-is-not-a-function/">this page</a> and you learned:</p>
<blockquote><p>
The reason was the statement &#8220;formObj.submit();&#8221; in the javascript was colliding (resulting in ambiguity within the browser) with the form button, which was also named &#8220;submit&#8221;.
</p></blockquote>
<p>So just rename the element within the form tag that is named &#8220;submit&#8221; will fix the problem.</p>
<p>Here&#8217;s an example.</p>
<p><b>HTML:</b><br />
<pre class="brush: xml; wrap-lines: false;">
&lt;form id=&quot;search&quot;&gt;&lt;input name=&quot;something&quot; /&gt;&lt;input type=&quot;submit&quot; name=&quot;submit&quot; /&gt;&lt;/form&gt;
</pre></p>
<p><b>Javascript:</b><br />
<pre class="brush: jscript; wrap-lines: false;">
function submitForm() {
  document.getElementById('search').submit();
}
</pre><br />
gives &#8220;submit is not a function&#8221; error.</p>
<p><strong>Change HTML to:</strong><br />
<pre class="brush: xml; wrap-lines: false;">
&lt;form id=&quot;search&quot;&gt;&lt;input name=&quot;something&quot; /&gt;&lt;input type=&quot;submit&quot; name=&quot;NOT_SUBMIT&quot; /&gt;&lt;/form&gt;
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pe20110517.wordpress.com/1333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pe20110517.wordpress.com/1333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pe20110517.wordpress.com/1333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pe20110517.wordpress.com/1333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pe20110517.wordpress.com/1333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pe20110517.wordpress.com/1333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pe20110517.wordpress.com/1333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pe20110517.wordpress.com/1333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pe20110517.wordpress.com/1333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pe20110517.wordpress.com/1333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pe20110517.wordpress.com/1333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pe20110517.wordpress.com/1333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pe20110517.wordpress.com/1333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pe20110517.wordpress.com/1333/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&#038;blog=23194870&#038;post=1333&#038;subd=pe20110517&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pure-essence.net/2008/10/15/javascript-error-submit-is-not-a-function/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fcfd5e14ca9c91790e95dfdb1d2ad756?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pureessence</media:title>
		</media:content>
	</item>
		<item>
		<title>jQuery plugin &#8211; tableRowCheckboxToggle</title>
		<link>http://pure-essence.net/2008/02/26/jquery-plugin-tablerowcheckboxtoggle/</link>
		<comments>http://pure-essence.net/2008/02/26/jquery-plugin-tablerowcheckboxtoggle/#comments</comments>
		<pubDate>Tue, 26 Feb 2008 20:58:41 +0000</pubDate>
		<dc:creator>pureessence</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[non php code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[table row]]></category>
		<category><![CDATA[toggle checkbox]]></category>

		<guid isPermaLink="false">http://regretless.com/2008/02/26/jquery-plugin-tablerowcheckboxtoggle/</guid>
		<description><![CDATA[So since I&#8217;ve been playing with jQuery on my spare time while putting together an ajax site, I&#8217;ve decided to tackle a design issue I&#8217;ve run into many times at work with jQuery. This idea originally comes from phpMyAdmin. If you&#8217;ve used that software, you know that when you click on any table row, it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&#038;blog=23194870&#038;post=1213&#038;subd=pe20110517&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So since I&#8217;ve been playing with jQuery on my spare time while putting together an ajax site, I&#8217;ve decided to tackle a design issue I&#8217;ve run into many times at work with jQuery. This idea originally comes from phpMyAdmin. If you&#8217;ve used that software, you know that when you click on any table row, it automatically toggles the checked state of the checkbox in the first cell. I think that&#8217;s an extremely user friendly thing to have since checkboxes are so small and hard to click on.</p>
<p>Let me present you my friends, my first jQuery plugin. It generically adds the toggle function to any table rows you specify based on the css class names. It will by default toggle any checkboxes within the table row. However, you can manually exclude checkboxes based on name, id or css classes in the script. In addition to the phpMyAdmin function, I added an initialization step in the script that correctly marks a row when it&#8217;s considered checked on page load.</p>
<h3>tableRowCheckboxToggle</h3>
<ul>
<li>It generically adds the toggle checkbox function to any table rows you specify based on the css class names.</li>
<li>It will by default toggle any checkboxes within the table row.</li>
<li>You can manually exclude checkboxes based on name, id or css classes in the script.</li>
<li>If there is any applicable checkboxes inside of the table row that are checked, it will apply a class to the table row.</li>
<li>It also marks table rows when there are checked applicable checkboxes on page load.</li>
</ul>
<p><a href="http://regretless.com/stuff/webTips/jquery.tableRowCheckboxToggle.zip">Download version 1.0</a></p>
<p><a href="http://regretless.com/stuff/webTips/jqueryTableRowCheckboxToggle.html">Live demonstration</a></p>
<p><a href="http://plugins.jquery.com/project/tableRowCheckboxToggle">jQuery plugin tableRowCheckboxToggle</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/pe20110517.wordpress.com/1213/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/pe20110517.wordpress.com/1213/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pe20110517.wordpress.com/1213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pe20110517.wordpress.com/1213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pe20110517.wordpress.com/1213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pe20110517.wordpress.com/1213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pe20110517.wordpress.com/1213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pe20110517.wordpress.com/1213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pe20110517.wordpress.com/1213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pe20110517.wordpress.com/1213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pe20110517.wordpress.com/1213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pe20110517.wordpress.com/1213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pe20110517.wordpress.com/1213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pe20110517.wordpress.com/1213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pe20110517.wordpress.com/1213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pe20110517.wordpress.com/1213/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&#038;blog=23194870&#038;post=1213&#038;subd=pe20110517&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pure-essence.net/2008/02/26/jquery-plugin-tablerowcheckboxtoggle/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fcfd5e14ca9c91790e95dfdb1d2ad756?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pureessence</media:title>
		</media:content>
	</item>
	</channel>
</rss>
