<?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>Brian Grinstead &#187; jquery</title>
	<atom:link href="http://www.briangrinstead.com/blog/tag/jquery/feed" rel="self" type="application/rss+xml" />
	<link>http://www.briangrinstead.com/blog</link>
	<description></description>
	<lastBuildDate>Wed, 11 Jan 2012 20:23:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>jQuery UI CDN Boilerplate</title>
		<link>http://www.briangrinstead.com/blog/jquery-ui-cdn-boilerplate</link>
		<comments>http://www.briangrinstead.com/blog/jquery-ui-cdn-boilerplate#comments</comments>
		<pubDate>Tue, 13 Dec 2011 22:13:21 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery-ui]]></category>

		<guid isPermaLink="false">http://www.briangrinstead.com/blog/?p=682</guid>
		<description><![CDATA[I always forget these links, and they are surprisingly hard to find. Here is a quick markup skeleton to throw together for prototypes using jQuery UI. &#60;!doctype html&#62; &#60;head&#62; &#60;title&#62;&#60;/title&#62; &#160; &#60;script type=&#34;text/javascript&#34; src=&#34;http://code.jquery.com/jquery-1.7.1.js&#34;&#62;&#60;/script&#62; &#60;script type=&#34;text/javascript&#34; src=&#34;http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js&#34;&#62;&#60;/script&#62; &#60;link rel=&#34;stylesheet&#34; type=&#34;text/css&#34; href=&#34;http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-lightness/jquery-ui.css&#34; /&#62; &#160; &#60;style type=&#34;text/css&#34;&#62; #draggable { background: orange; width: 100px; height: 100px; } &#60;/style&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>I always forget these links, and they are surprisingly hard to find.  Here is a quick markup skeleton to throw together for prototypes using jQuery UI.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;!doctype html&gt;
&lt;head&gt;
  &lt;title&gt;&lt;/title&gt;
&nbsp;
  &lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-1.7.1.js&quot;&gt;&lt;/script&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js&quot;&gt;&lt;/script&gt;
  &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-lightness/jquery-ui.css&quot; /&gt;
&nbsp;
  &lt;style type=&quot;text/css&quot;&gt;
    #draggable {
		background: orange;
		width: 100px;
		height: 100px;
	}
  &lt;/style&gt;
&nbsp;
  &lt;script type='text/javascript'&gt;
	$(function() {
		$(&quot;#draggable&quot;).draggable().resizable();
	});
  &lt;/script&gt;
&lt;/head&gt;
&nbsp;
&lt;body&gt;
&lt;div id='draggable'&gt;drag!&lt;/div&gt;
&lt;/body&gt;
&nbsp;
&lt;/html&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.briangrinstead.com/blog/jquery-ui-cdn-boilerplate/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Keep Aspect Ratio With HTML and CSS</title>
		<link>http://www.briangrinstead.com/blog/keep-aspect-ratio-with-html-and-css</link>
		<comments>http://www.briangrinstead.com/blog/keep-aspect-ratio-with-html-and-css#comments</comments>
		<pubDate>Wed, 28 Sep 2011 17:51:31 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[colorpicker]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.briangrinstead.com/blog/?p=601</guid>
		<description><![CDATA[When working on my javascript colorpicker, one of the things I thought would be really cool is if you could resize it and have the colorpicker automatically respond to different widths. When I first made it, I had basically defined static widths with the thought that there could be different themes (small, normal, large) which [...]]]></description>
			<content:encoded><![CDATA[<p>When working on my <a href='http://bgrins.github.com/spectrum/'>javascript colorpicker</a>, one of the things I thought would be really cool is if you could resize it and have the colorpicker automatically respond to different widths.  When I first made it, I had basically <a href='https://github.com/bgrins/spectrum/commit/aa54da8f1b76a75ef165f6433441fd006a7c22c5#L0R223'>defined static widths</a> with the thought that there could be different themes (small, normal, large) which defined different widths.  </p>
<p>This turned out to be a pain, since you had to manually figure out what each width needed to be for the total size.  To complicate things further, I wanted to have a different percentage width when accessing the colorpicker via an iPhone.  I found that the hue slider was a little too small to accurately slide with the touch interface, so I wanted it to take up more of a percentage of the total width.  I&#8217;m can be lazy about calculating widths in CSS, so I went off looking for a different way to do this.</p>
<h2>Aspect Ratios</h2>
<p>Why couldn&#8217;t I just use percentage widths?  Because the left portion of the colorpicker needs to be a square &#8211; or else the gradients for saturation and value just look weird and don&#8217;t really map up 1:1.  I did some searching and found a <a href='http://ansciath.tumblr.com/post/7347495869/css-aspect-ratio'>CSS workaround to keep the aspect ratio</a> of a fluid element by ansciath.  The meat of this trick is that <a href='http://www.w3.org/TR/CSS2/box.html#propdef-margin-top'>according to the spec for margin-top</a>, a percentage refers to the <em>width</em> of the containing block, not the height.  This post got me much of the way there, but I had to include a couple of fixes for IE and ways.</p>
<p><em>The really nice part about using this technique is that it makes spectrum extremely easy to skin in your own CSS.</em>  Check out <a href='http://briangrinstead.com/colorstash'>ColorStash</a> for an example of this.  Using media queries and max-widths, I can change the width of the colorpicker as the browser resizes to get some really responsive behavior on a UI control (colorpicker) that has typically been very static.</p>
<h2>Demo</h2>
<p>See the <a href='http://jsfiddle.net/bgrins/zpWNF/embedded/result/'>demo of the aspect ratio  and media query</a>.  Try resizing your browser window to under 480px width to see the switch happen.  Here is the full <a href='http://jsfiddle.net/bgrins/zpWNF/'>source code</a> for the demo.</p>
<p>Below is a snippet showing the basic HTML/CSS needed for this technique:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div class='container'&gt;
    &lt;div class='outer'&gt;
        &lt;div class='fill'&gt;&lt;/div&gt;
        &lt;div class='inner-top'&gt;
            &lt;div class='square'&gt;Always a square&lt;/div&gt;
            &lt;div class='right'&gt;% width&lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class='bottom'&gt;
        Bottom
    &lt;/div&gt;
&lt;/div&gt;</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.outer</span> <span style="color: #00AA00;color: #000000;">&#123;</span>
  <span style="color: #000000; font-weight: bold;color: #0000FF;">position</span><span style="color: #00AA00;color: #000000;">:</span><span style="color: #993333;color: #0000FF;">relative</span><span style="color: #00AA00;color: #000000;">;</span> 
  <span style="color: #000000; font-weight: bold;color: #0000FF;">width</span><span style="color: #00AA00;color: #000000;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;color: #000000;">;</span>
  <span style="color: #000000; font-weight: bold;color: #0000FF;">display</span><span style="color: #00AA00;color: #000000;">:</span>inline-<span style="color: #993333;color: #0000FF;">block</span><span style="color: #00AA00;color: #000000;">;</span>
<span style="color: #00AA00;color: #000000;">&#125;</span>
.inner-<span style="color: #000000; font-weight: bold;color: #0000FF;">top</span> <span style="color: #00AA00;color: #000000;">&#123;</span>
   <span style="color: #000000; font-weight: bold;color: #0000FF;">position</span><span style="color: #00AA00;color: #000000;">:</span><span style="color: #993333;color: #0000FF;">absolute</span><span style="color: #00AA00;color: #000000;">;</span> <span style="color: #000000; font-weight: bold;color: #0000FF;">top</span><span style="color: #00AA00;color: #000000;">:</span><span style="color: #cc66cc;color: #808080;">0</span><span style="color: #00AA00;color: #000000;">;</span> <span style="color: #000000; font-weight: bold;color: #0000FF;">left</span><span style="color: #00AA00;color: #000000;">:</span><span style="color: #cc66cc;color: #808080;">0</span><span style="color: #00AA00;color: #000000;">;</span> <span style="color: #000000; font-weight: bold;color: #0000FF;">bottom</span><span style="color: #00AA00;color: #000000;">:</span><span style="color: #cc66cc;color: #808080;">0</span><span style="color: #00AA00;color: #000000;">;</span> <span style="color: #000000; font-weight: bold;color: #0000FF;">right</span><span style="color: #00AA00;color: #000000;">:</span><span style="color: #cc66cc;color: #808080;">0</span><span style="color: #00AA00;color: #000000;">;</span>
<span style="color: #00AA00;color: #000000;">&#125;</span>
.<span style="color: #993333;color: #0000FF;">square</span> <span style="color: #00AA00;color: #000000;">&#123;</span>    
    <span style="color: #000000; font-weight: bold;color: #0000FF;">position</span><span style="color: #00AA00;color: #000000;">:</span> <span style="color: #993333;color: #0000FF;">absolute</span><span style="color: #00AA00;color: #000000;">;</span>
    <span style="color: #000000; font-weight: bold;color: #0000FF;">top</span><span style="color: #00AA00;color: #000000;">:</span><span style="color: #cc66cc;color: #808080;">0</span><span style="color: #00AA00;color: #000000;">;</span>left<span style="color: #00AA00;color: #000000;">:</span><span style="color: #cc66cc;color: #808080;">0</span><span style="color: #00AA00;color: #000000;">;</span>bottom<span style="color: #00AA00;color: #000000;">:</span><span style="color: #cc66cc;color: #808080;">0</span><span style="color: #00AA00;color: #000000;">;</span>right<span style="color: #00AA00;color: #000000;">:</span><span style="color: #933;">20%</span><span style="color: #00AA00;color: #000000;">;</span>
    <span style="color: #000000; font-weight: bold;color: #0000FF;">background</span><span style="color: #00AA00;color: #000000;">:</span>orange<span style="color: #00AA00;color: #000000;">;</span> 
<span style="color: #00AA00;color: #000000;">&#125;</span>
.<span style="color: #000000; font-weight: bold;color: #0000FF;">right</span> <span style="color: #00AA00;color: #000000;">&#123;</span>
    <span style="color: #000000; font-weight: bold;color: #0000FF;">position</span><span style="color: #00AA00;color: #000000;">:</span> <span style="color: #993333;color: #0000FF;">absolute</span><span style="color: #00AA00;color: #000000;">;</span>
    <span style="color: #000000; font-weight: bold;color: #0000FF;">top</span><span style="color: #00AA00;color: #000000;">:</span><span style="color: #cc66cc;color: #808080;">0</span><span style="color: #00AA00;color: #000000;">;</span>right<span style="color: #00AA00;color: #000000;">:</span><span style="color: #cc66cc;color: #808080;">0</span><span style="color: #00AA00;color: #000000;">;</span>bottom<span style="color: #00AA00;color: #000000;">:</span><span style="color: #cc66cc;color: #808080;">0</span><span style="color: #00AA00;color: #000000;">;</span>left<span style="color: #00AA00;color: #000000;">:</span><span style="color: #933;">83%</span><span style="color: #00AA00;color: #000000;">;</span>
    <span style="color: #000000; font-weight: bold;color: #0000FF;">background</span><span style="color: #00AA00;color: #000000;">:</span> <span style="color: #993333;color: #0000FF;">purple</span><span style="color: #00AA00;color: #000000;">;</span>
<span style="color: #00AA00;color: #000000;">&#125;</span>
<span style="color: #6666ff;">.fill</span> <span style="color: #00AA00;color: #000000;">&#123;</span> 
    <span style="color: #00AA00;color: #000000;">*</span><span style="color: #000000; font-weight: bold;color: #0000FF;">height</span><span style="color: #00AA00;color: #000000;">:</span> <span style="color: #933;">80%</span><span style="color: #00AA00;color: #000000;">;</span>
    <span style="color: #000000; font-weight: bold;color: #0000FF;">margin-top</span><span style="color: #00AA00;color: #000000;">:</span> <span style="color: #933;">80%</span><span style="color: #00AA00;color: #000000;">;</span>  <span style="color: #808080; font-style: italic;color: #008000;">/* Same as square width */</span>
<span style="color: #00AA00;color: #000000;">&#125;</span>
<span style="color: #a1a100;color: #008000;">@media (max-width: 480px) {</span>
    .<span style="color: #993333;color: #0000FF;">square</span> <span style="color: #00AA00;color: #000000;">&#123;</span> <span style="color: #000000; font-weight: bold;color: #0000FF;">right</span><span style="color: #00AA00;color: #000000;">:</span> <span style="color: #933;">51%</span><span style="color: #00AA00;color: #000000;">;</span> <span style="color: #000000; font-weight: bold;color: #0000FF;">background</span><span style="color: #00AA00;color: #000000;">:</span> <span style="color: #000000; font-weight: bold;color: #0000FF;">blue</span><span style="color: #00AA00;color: #000000;">;</span> <span style="color: #00AA00;color: #000000;">&#125;</span>
    .<span style="color: #000000; font-weight: bold;color: #0000FF;">right</span> <span style="color: #00AA00;color: #000000;">&#123;</span> <span style="color: #000000; font-weight: bold;color: #0000FF;">left</span><span style="color: #00AA00;color: #000000;">:</span> <span style="color: #933;">51%</span><span style="color: #00AA00;color: #000000;">;</span> <span style="color: #00AA00;color: #000000;">&#125;</span>
    <span style="color: #6666ff;">.fill</span> <span style="color: #00AA00;color: #000000;">&#123;</span> <span style="color: #000000; font-weight: bold;color: #0000FF;">margin-top</span><span style="color: #00AA00;color: #000000;">:</span> <span style="color: #933;">49%</span><span style="color: #00AA00;color: #000000;">;</span> <span style="color: #00AA00;color: #000000;">&#125;</span> 
<span style="color: #00AA00;color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.briangrinstead.com/blog/keep-aspect-ratio-with-html-and-css/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What I want in a JavaScript colorpicker</title>
		<link>http://www.briangrinstead.com/blog/javascript-colorpicker</link>
		<comments>http://www.briangrinstead.com/blog/javascript-colorpicker#comments</comments>
		<pubDate>Mon, 05 Sep 2011 02:21:31 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.briangrinstead.com/blog/?p=558</guid>
		<description><![CDATA[I have been wanting to add colorpickers in a couple of projects recently, and was not happy with the options. Just search JavaScript Colorpicker and you&#8217;ll see what I mean. It got me thinking about what I wanted out of a colorpicker. No Images! It is pretty well known that you should limit the number [...]]]></description>
			<content:encoded><![CDATA[<p>I have been wanting to add colorpickers in a couple of projects recently, and was not happy with the options.  Just search <a href='http://www.google.com/search?q=javascript+colorpicker'>JavaScript Colorpicker</a> and you&#8217;ll see what I mean.  It got me thinking about what I wanted out of a colorpicker.</p>
<h2>No Images!</h2>
<p>It is pretty well known that you should limit the number of images that your web page requests for performance reasons.  Some of these, including the <a href='http://www.eyecon.ro/colorpicker/'>eyecon.ro</a> picker, which is the first that shows up when searching &#8216;jQuery colorpicker&#8217;, require a ton of images (27, in fact).  This is overkill.  Why can&#8217;t it be skinned with HTML/CSS? </p>
<h2>Reasonable defaults</h2>
<p>I found myself having to dig through the source code of various colorpickers in order to get them to act how I wanted.  Maybe my experience on this is unique, but once I wanted to actually script behavior to go along with the picker (think &#8211; a template editor for an online portfolio), it became painful quickly.</p>
<h2>Browser Support</h2>
<p>It needs to support all major browsers (even IE).  Ideally it could also support mobile devices.</p>
<h2>Drop in</h2>
<p>Didn&#8217;t want to have to download zip folders, place a bunch of images in my project and modify css files to point to the correct image path, etc.  I just want to include a single JavaScript file, and a single CSS file, and be done.</p>
<h2>Anything Like This?</h2>
<p>I did find the nifty <a href='https://github.com/DavidDurman/FlexiColorPicker'>FlexiColorPicker</a>, which accomplishes the no images goal with SVG and VML.  It seems very nice, but didn&#8217;t have some of the features I wanted (dragging around the hue slider and picker didn&#8217;t actually work).  I&#8217;m glad I found it, as I did use some of the gradients as a starting point with my CSS gradients.</p>
<h2>Spectrum &#8211; My JavaScript Colorpicker</h2>
<p>I have done a fair amount of color manipulation work while building a color scheme generator in a theme editor.  I also have made a JavaScript color micro framework for parsing and conversion, called <a href='https://github.com/bgrins/TinyColor'>TinyColor</a>.  This is designed to allow a wide range of input and output (named colors, hex, rgb, hsl, hsv).  </p>
<p>So, I decided to try my hand at this, and made the <a href="http://bgrins.github.com/spectrum/">spectrum JavaScript colorpicker</a>.</p>
<p>It works in all major browsers (tested in Safari, Chrome, Firefox, IE 7+, iOS, Opera).  It uses IE&#8217;s propriety gradient filter (with some hacks for the hue slider &#8211; see .spectrum-ie-1 through 8 in <a href='https://github.com/bgrins/spectrum/blob/master/spectrum.css'>spectrum.css</a>.  It should even work in iPhone and iPad &#8211; let me know if you have one and can double check that for me over on the demo page :).  It is still in early stages, but I would love if I could get some feedback on the UI and desired functionality.</p>
<h2>Demo</h2>
<p>Head over to the current <a href='http://bgrins.github.com/spectrum/'>project page</a> to try out the demo and see the docs.</p>
<p>It currently requires jQuery, but I have been trying to write the code to make it possible to remove that dependancy.</p>
<p><a href="http://bgrins.github.com/spectrum/"><img src="http://briangrinstead.com/files/Picture-4.png" alt="" title="Spectrum JavaScript Colorpicker" width="754" height="319" class="aligncenter size-full wp-image-565" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.briangrinstead.com/blog/javascript-colorpicker/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>bindWithDelay jQuery Plugin &#8211; Now With Throttling</title>
		<link>http://www.briangrinstead.com/blog/bindwithdelay-throttling</link>
		<comments>http://www.briangrinstead.com/blog/bindwithdelay-throttling#comments</comments>
		<pubDate>Sat, 14 May 2011 00:27:46 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[bindwithdelay]]></category>
		<category><![CDATA[event binding]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.briangrinstead.com/blog/?p=522</guid>
		<description><![CDATA[I decided to add in throttling functionality to the jquery bindWithDelay plugin. This is a nice feature that didn&#8217;t require very many changes to the code (see the: diff). What is throttling? Imagine you are scrolling down a long page for 3 seconds and you have bindWithDelay running with a timeout of 1000ms. By default, [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to add in throttling functionality to the <a href='http://briangrinstead.com/files/bindWithDelay/'>jquery bindWithDelay</a> plugin.  This is a nice feature that didn&#8217;t require very many changes to the code (see the: <a href='https://github.com/bgrins/bindWithDelay/commit/e23c2502458c516e24dd0b16edcde8b2f1636f3f#diff-0'>diff</a>).</p>
<h3>What is throttling?</h3>
<p>Imagine you are scrolling down a long page for 3 seconds and you have bindWithDelay running with a timeout of 1000ms. By default, your event will only fire a second after you have completely finished scrolling. If you have the optional throttling on, it will fire once per second during the scrolling &#8211; a total of 3 times instead of 1.</p>
<p>Checkout the <a href='http://briangrinstead.com/files/bindWithDelay#example'>throttling demo</a> to see what it is doing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.briangrinstead.com/blog/bindwithdelay-throttling/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>filereader.js &#8211; A Lightweight FileReader Wrapper</title>
		<link>http://www.briangrinstead.com/blog/filereaderjs</link>
		<comments>http://www.briangrinstead.com/blog/filereaderjs#comments</comments>
		<pubDate>Sun, 14 Nov 2010 07:33:13 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[filereader]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.briangrinstead.com/blog/?p=438</guid>
		<description><![CDATA[filereader.js is lighweight wrapper for the JavaScript FileReader interface.]]></description>
			<content:encoded><![CDATA[<p>I am working on project that needs to read local files.  This relies on the FileReader interface, and I couldn&#8217;t find any JavaScript libraries to help out with common usage for this, so I made one.</p>
<p>FileReader is a JavaScript interface that allows you to read local files as binary.  This is available in <a href='http://caniuse.com/#feat=fileapi'>supported browsers</a> when a user drags and drops files into a browser window or selects files from an input with a type of file.  See the <a href='http://dev.w3.org/2006/webapi/FileAPI/#FileReader-interface'>FileReader specification</a> for more information.</p>
<p>filereader.js is a wrapper for accessing this functionality.  It can be called using:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">FileReaderJS.<span style="color: #660066;">setupInput</span><span style="color: #009900;color: #000000;">&#40;</span>fileInput<span style="color: #339933;color: #000000;">,</span> opts<span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
FileReaderJS.<span style="color: #660066;">setupDrop</span><span style="color: #009900;color: #000000;">&#40;</span>dropbox<span style="color: #339933;color: #000000;">,</span> opts<span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span></pre></div></div>

<p>If you use jQuery, you can access these calls with:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;#fileInput&quot;</span><span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">fileReaderJS</span><span style="color: #009900;color: #000000;">&#40;</span>opts<span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
$<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;#dropbox&quot;</span><span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">fileReaderJS</span><span style="color: #009900;color: #000000;">&#40;</span>opts<span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span></pre></div></div>

<p>To see the full range of options and functionality, view the <a href='https://github.com/bgrins/filereader.js/blob/master/README'>readme</a>.</p>
<p>filereader.js is available under the MIT License.  See the full <a href="http://github.com/bgrins/filereader.js">filereader.js code</a> or the single file <a href='https://github.com/bgrins/filereader.js/raw/master/filereader.js'>raw javascript source</a> on github.</p>
<p>You can see an example project using filereader.js on Instant Sprite, a browser based <a href="http://instantsprite.com">CSS Sprite Generator</a> that I am working on.  Try dragging images onto the body, or clicking to add multiple image files to see what is possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.briangrinstead.com/blog/filereaderjs/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bindWithDelay jQuery Plugin</title>
		<link>http://www.briangrinstead.com/blog/bindwithdelay-jquery-plugin</link>
		<comments>http://www.briangrinstead.com/blog/bindwithdelay-jquery-plugin#comments</comments>
		<pubDate>Tue, 10 Aug 2010 18:26:31 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[bindwithdelay]]></category>
		<category><![CDATA[event binding]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.briangrinstead.com/blog/?p=380</guid>
		<description><![CDATA[Sometimes, I want to have a JavaScript event that doesn&#8217;t fire until the native event stops firing for a short timeout. I&#8217;ve needed to use that pattern in almost every project I have worked on. For example, you want to use JavaScript to resize an iframe to 100% height when the window resizes. The resize() [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, I want to have a JavaScript event that doesn&#8217;t fire until the native event stops firing for a short timeout.  I&#8217;ve needed to use that pattern in almost every project I have worked on.</p>
<p><strong>For example</strong>, you want to use JavaScript to resize an iframe to 100% height when the window resizes.  The resize() event can fire dozens of times, and calculating and setting the new height can slow down your page.  I used to implement it like this (notice the extra global variable and indentation with the anonymous function):</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;color: #0000FF;">var</span> timeout<span style="color: #339933;color: #000000;">;</span>
<span style="color: #003366; font-weight: bold;color: #0000FF;">function</span> doResize<span style="color: #009900;color: #000000;">&#40;</span>e<span style="color: #009900;color: #000000;">&#41;</span> <span style="color: #009900;color: #000000;">&#123;</span>
   clearTimeout<span style="color: #009900;color: #000000;">&#40;</span>timeout<span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
   timeout <span style="color: #339933;color: #000000;">=</span> setTimeout<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #003366; font-weight: bold;color: #0000FF;">function</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #009900;color: #000000;">&#41;</span> <span style="color: #009900;color: #000000;">&#123;</span>
      <span style="color: #006600; font-style: italic;color: #008000;">// run some code</span>
   <span style="color: #009900;color: #000000;">&#125;</span><span style="color: #339933;color: #000000;">,</span> <span style="color: #CC0000;color: #808080;">200</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
<span style="color: #009900;color: #000000;">&#125;</span>
$<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #003366; font-weight: bold;color: #0000FF;">function</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #009900;color: #000000;">&#41;</span> <span style="color: #009900;color: #000000;">&#123;</span>
   $<span style="color: #009900;color: #000000;">&#40;</span>window<span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;resize&quot;</span><span style="color: #339933;color: #000000;">,</span>doResize<span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
<span style="color: #009900;color: #000000;">&#125;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span></pre></div></div>

<p><strong>I wrote a plugin to make this pattern easier, it is called &#8220;bindWithDelay&#8221;.</strong>  The <a href='http://github.com/bgrins/bindWithDelay/'>source code</a> is online, as is a mini <a href='http://briangrinstead.com/files/bindWithDelay/'>project page</a> with a demo.</p>
<p>
This is what the same code looks like with the plugin:
</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;color: #0000FF;">function</span> doResize<span style="color: #009900;color: #000000;">&#40;</span>e<span style="color: #009900;color: #000000;">&#41;</span> <span style="color: #009900;color: #000000;">&#123;</span>
      <span style="color: #006600; font-style: italic;color: #008000;">// run some code</span>
<span style="color: #009900;color: #000000;">&#125;</span>
$<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #003366; font-weight: bold;color: #0000FF;">function</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #009900;color: #000000;">&#41;</span> <span style="color: #009900;color: #000000;">&#123;</span>
   $<span style="color: #009900;color: #000000;">&#40;</span>window<span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">bindWithDelay</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;resize&quot;</span><span style="color: #339933;color: #000000;">,</span> doResize<span style="color: #339933;color: #000000;">,</span> <span style="color: #CC0000;color: #808080;">200</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
<span style="color: #009900;color: #000000;">&#125;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.briangrinstead.com/blog/bindwithdelay-jquery-plugin/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make Table Rows Sortable Using jQuery UI Sortable</title>
		<link>http://www.briangrinstead.com/blog/make-table-rows-sortable-using-jquery-ui-sortable</link>
		<comments>http://www.briangrinstead.com/blog/make-table-rows-sortable-using-jquery-ui-sortable#comments</comments>
		<pubDate>Thu, 30 Jul 2009 20:17:51 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[cell]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery-ui]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sortable]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://www.briangrinstead.com/blog/?p=352</guid>
		<description><![CDATA[I wrote an article, Make Table Rows Sortable Using jQuery UI Sortable on the Foliotek Development Blog about a problem that I ran into when trying to set up a basic sortable table using jQuery UI. The columns would collapse down once the dragging began. This was fixed by adjusting the helper object for the [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote an article, <em><a href='http://www.foliotek.com/devblog/make-table-rows-sortable-using-jquery-ui-sortable/'>Make Table Rows Sortable Using jQuery UI Sortable</a></em> on the <a href='http://www.foliotek.com/devblog'>Foliotek Development Blog</a> about a problem that I ran into when trying to set up a basic sortable table using jQuery UI.  The columns would collapse down once the dragging began.  </p>
<p><img src="http://briangrinstead.com/files/sotable-row-collapsed.png" alt="sortable-row-collapsed" title="sortable-row-collapsed" class="aligncenter size-full" /></p>
<p>This was fixed by adjusting the <a href='http://jqueryui.com/demos/sortable/#option-helper'>helper object</a> for the sortable function.  Check out the [article][] for all the details, but here is a sample of the code if you are just looking for the solution:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;color: #008000;">// Return a helper with preserved width of cells</span>
<span style="color: #003366; font-weight: bold;color: #0000FF;">var</span> fixHelper <span style="color: #339933;color: #000000;">=</span> <span style="color: #003366; font-weight: bold;color: #0000FF;">function</span><span style="color: #009900;color: #000000;">&#40;</span>e<span style="color: #339933;color: #000000;">,</span> ui<span style="color: #009900;color: #000000;">&#41;</span> <span style="color: #009900;color: #000000;">&#123;</span>
	ui.<span style="color: #660066;">children</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #003366; font-weight: bold;color: #0000FF;">function</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #009900;color: #000000;">&#41;</span> <span style="color: #009900;color: #000000;">&#123;</span>
		$<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;color: #0000FF;">this</span><span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;color: #000000;">&#40;</span>$<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;color: #0000FF;">this</span><span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
	<span style="color: #009900;color: #000000;">&#125;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
	<span style="color: #000066; font-weight: bold;color: #0000FF;">return</span> ui<span style="color: #339933;color: #000000;">;</span>
<span style="color: #009900;color: #000000;">&#125;</span><span style="color: #339933;color: #000000;">;</span>
&nbsp;
$<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;#sort tbody&quot;</span><span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">sortable</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #009900;color: #000000;">&#123;</span>
	helper<span style="color: #339933;color: #000000;">:</span> fixHelper
<span style="color: #009900;color: #000000;">&#125;</span><span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">disableSelection</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.briangrinstead.com/blog/make-table-rows-sortable-using-jquery-ui-sortable/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Keep Original Variable State Between Event Binding and Execution</title>
		<link>http://www.briangrinstead.com/blog/keep-original-variable-state-between-event-binding-and-execution</link>
		<comments>http://www.briangrinstead.com/blog/keep-original-variable-state-between-event-binding-and-execution#comments</comments>
		<pubDate>Wed, 15 Jul 2009 13:48:09 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[closure]]></category>
		<category><![CDATA[event binding]]></category>
		<category><![CDATA[event handling]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[variable scope]]></category>

		<guid isPermaLink="false">http://www.briangrinstead.com/blog/?p=291</guid>
		<description><![CDATA[Or: Binding Events Inside of a Loop with jQuery I wrote an article on the Foliotek Development Blog about saving the state of a variable inside a closure that is not executed immediately. For example, functions passed into event binding or setTimeout(). Here is a quick rundown of the problem and the solution (using the [...]]]></description>
			<content:encoded><![CDATA[<h3>Or: Binding Events Inside of a Loop with jQuery</h3>
<p>I <a href='http://www.foliotek.com/devblog/keep-variable-state-between-event-binding-and-execution/'>wrote an article on the Foliotek Development Blog</a> about saving the state of a variable inside a closure that is not executed immediately. For example, functions passed into event binding or setTimeout(). Here is a quick rundown of the problem and the solution (using the jQuery library). </p>
<h3>The Problem</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #003366; font-weight: bold;color: #0000FF;">function</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #009900;color: #000000;">&#41;</span> <span style="color: #009900;color: #000000;">&#123;</span>
	$<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;body&quot;</span><span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;&lt;ul id='container'&gt;&lt;/ul&gt;&quot;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;color: #0000FF;">for</span> <span style="color: #009900;color: #000000;">&#40;</span><span style="color: #003366; font-weight: bold;color: #0000FF;">var</span> i <span style="color: #339933;color: #000000;">=</span> <span style="color: #CC0000;color: #808080;">0</span><span style="color: #339933;color: #000000;">;</span> i <span style="color: #339933;color: #000000;">&lt;</span> <span style="color: #CC0000;color: #808080;">5</span><span style="color: #339933;color: #000000;">;</span> i<span style="color: #339933;color: #000000;">++</span><span style="color: #009900;color: #000000;">&#41;</span>
	<span style="color: #009900;color: #000000;">&#123;</span>
		<span style="color: #003366; font-weight: bold;color: #0000FF;">var</span> $item <span style="color: #339933;color: #000000;">=</span> $<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;&lt;li /&gt;&quot;</span><span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;Item &quot;</span> <span style="color: #339933;color: #000000;">+</span> i<span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
		$<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;#container&quot;</span><span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;color: #000000;">&#40;</span>$item<span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
&nbsp;
		$item.<span style="color: #660066;">click</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #003366; font-weight: bold;color: #0000FF;">function</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #009900;color: #000000;">&#41;</span> <span style="color: #009900;color: #000000;">&#123;</span>
			<span style="color: #000066;color: #0000FF;">alert</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;You clicked number &quot;</span> <span style="color: #339933;color: #000000;">+</span> i<span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>  <span style="color: #006600; font-style: italic;color: #008000;">// always &quot;You clicked number 5&quot;</span>
		<span style="color: #009900;color: #000000;">&#125;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
	<span style="color: #009900;color: #000000;">&#125;</span>
<span style="color: #009900;color: #000000;">&#125;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span></pre></div></div>

<h3>The Solution</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #003366; font-weight: bold;color: #0000FF;">function</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #009900;color: #000000;">&#41;</span> <span style="color: #009900;color: #000000;">&#123;</span>
	$<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;body&quot;</span><span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;&lt;ul id='container'&gt;&lt;/ul&gt;&quot;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;color: #0000FF;">for</span> <span style="color: #009900;color: #000000;">&#40;</span><span style="color: #003366; font-weight: bold;color: #0000FF;">var</span> i <span style="color: #339933;color: #000000;">=</span> <span style="color: #CC0000;color: #808080;">0</span><span style="color: #339933;color: #000000;">;</span> i <span style="color: #339933;color: #000000;">&lt;</span> <span style="color: #CC0000;color: #808080;">5</span><span style="color: #339933;color: #000000;">;</span> i<span style="color: #339933;color: #000000;">++</span><span style="color: #009900;color: #000000;">&#41;</span>
	<span style="color: #009900;color: #000000;">&#123;</span>
		<span style="color: #003366; font-weight: bold;color: #0000FF;">var</span> $item <span style="color: #339933;color: #000000;">=</span> $<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;&lt;li /&gt;&quot;</span><span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;Item &quot;</span> <span style="color: #339933;color: #000000;">+</span> i<span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
		$<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;#container&quot;</span><span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;color: #000000;">&#40;</span>$item<span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
&nbsp;
		<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #003366; font-weight: bold;color: #0000FF;">function</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #009900;color: #000000;">&#41;</span> <span style="color: #009900;color: #000000;">&#123;</span> <span style="color: #006600; font-style: italic;color: #008000;">// Closure here here instead of &quot;bindItem()&quot;</span>
			<span style="color: #003366; font-weight: bold;color: #0000FF;">var</span> ind <span style="color: #339933;color: #000000;">=</span> i<span style="color: #339933;color: #000000;">;</span>
			$item.<span style="color: #660066;">click</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #003366; font-weight: bold;color: #0000FF;">function</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #009900;color: #000000;">&#41;</span> <span style="color: #009900;color: #000000;">&#123;</span>
				<span style="color: #000066;color: #0000FF;">alert</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;You clicked number &quot;</span> <span style="color: #339933;color: #000000;">+</span> ind<span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span> <span style="color: #006600; font-style: italic;color: #008000;">// Works as expected</span>
			<span style="color: #009900;color: #000000;">&#125;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
		<span style="color: #009900;color: #000000;">&#125;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span> <span style="color: #006600; font-style: italic;color: #008000;">// Execute immediately</span>
	<span style="color: #009900;color: #000000;">&#125;</span>
<span style="color: #009900;color: #000000;">&#125;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span></pre></div></div>

<p>The solution uses an immediately executing function to create a new scope and declare a variable &#8220;ind&#8221; that is reserved a new space in memory instead of simply referencing &#8220;i&#8221;. Check out the <a href='http://www.foliotek.com/devblog/keep-variable-state-between-event-binding-and-execution/'>full article</a> for more details.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.briangrinstead.com/blog/keep-original-variable-state-between-event-binding-and-execution/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery outerHTML Snippet</title>
		<link>http://www.briangrinstead.com/blog/jquery-outerhtml-snippet</link>
		<comments>http://www.briangrinstead.com/blog/jquery-outerhtml-snippet#comments</comments>
		<pubDate>Tue, 16 Jun 2009 13:29:16 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://www.briangrinstead.com/?p=246</guid>
		<description><![CDATA[outerHTML is a property that is provided by Internet Explorer that returns the full HTML of an element (including start and end tags). In jQuery, the html() function returns the innerHTML of an element, which is just the HTML inside the element (not including the start and end tags). There came a time that I [...]]]></description>
			<content:encoded><![CDATA[<p><code>outerHTML</code> is a property that is provided by Internet Explorer that returns the full HTML of an element (including start and end tags).  In jQuery, the html() function returns the <code>innerHTML</code> of an element, which is just the HTML inside the element (not including the start and end tags).</p>
<p>There came a time that I wanted to get the <code>outerHTML</code> of an element, and I found that <a href="http://brandonaaron.net/blog/2007/06/17/jquery-snippets-outerhtml/">Brandon Aaron</a> shared a jQuery code snippet that does this exactly.  It does the trick for most cases, but there was one problem that I ran into.  <em>I wanted to get the outerHTML of an element inside of an iframe</em>, and I got a &#8216;Permission Denied&#8217; error in Internet Explorer.  </p>
<p>The problem was that it was appending an element belonging to the iframes &#8216;contentDocument&#8217; into an element belonging to the global &#8216;document&#8217; element.<br />
Using the <a href="http://docs.jquery.com/Core/jQuery#htmlownerDocument">jQuery(html, ownerDocument)</a> overload of the jQuery core function, this error was fixed:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">outerHTML</span> <span style="color: #339933;color: #000000;">=</span> <span style="color: #003366; font-weight: bold;color: #0000FF;">function</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #009900;color: #000000;">&#41;</span> <span style="color: #009900;color: #000000;">&#123;</span>
    <span style="color: #003366; font-weight: bold;color: #0000FF;">var</span> doc <span style="color: #339933;color: #000000;">=</span> <span style="color: #000066; font-weight: bold;color: #0000FF;">this</span><span style="color: #009900;color: #000000;">&#91;</span><span style="color: #CC0000;color: #808080;">0</span><span style="color: #009900;color: #000000;">&#93;</span> <span style="color: #339933;color: #000000;">?</span> <span style="color: #000066; font-weight: bold;color: #0000FF;">this</span><span style="color: #009900;color: #000000;">&#91;</span><span style="color: #CC0000;color: #808080;">0</span><span style="color: #009900;color: #000000;">&#93;</span>.<span style="color: #660066;">ownerDocument</span> <span style="color: #339933;color: #000000;">:</span> document<span style="color: #339933;color: #000000;">;</span>
    <span style="color: #000066; font-weight: bold;color: #0000FF;">return</span> $<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">'&lt;div&gt;'</span><span style="color: #339933;color: #000000;">,</span> doc<span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;color: #0000FF;">this</span>.<span style="color: #660066;">eq</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #CC0000;color: #808080;">0</span><span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">clone</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;color: #000000;">&#40;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
<span style="color: #009900;color: #000000;">&#125;</span><span style="color: #339933;color: #000000;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.briangrinstead.com/blog/jquery-outerhtml-snippet/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Extending jQuery to Select ASP Controls</title>
		<link>http://www.briangrinstead.com/blog/extending-jquery-to-select-asp-controls</link>
		<comments>http://www.briangrinstead.com/blog/extending-jquery-to-select-asp-controls#comments</comments>
		<pubDate>Mon, 08 Jun 2009 18:54:30 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.briangrinstead.com/?p=226</guid>
		<description><![CDATA[One thing that has always been annoying about programming JavaScript in an ASP.NET Web Forms environment is that the ID attribute of HTML controls rendered out from ASP controls is unpredictable. &#60;asp:TextBox runat=&#34;server&#34; ID=&#34;txtPhoneNumber&#34; /&#62; renders out as something like: &#60;input type=&#34;text&#34; id=&#34;ctl00_ctl00_ctl00_main_Content_txtPhoneNumber&#34; name=&#34;ctl00$ctl00$ctl00$main$Content$txtPhoneNumber&#34; /&#62; I did a write up over on the LANIT development [...]]]></description>
			<content:encoded><![CDATA[<p>One thing that has always been annoying about programming JavaScript in an ASP.NET Web Forms environment is that the ID attribute of HTML controls rendered out from ASP controls is unpredictable.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">	&lt;asp:TextBox runat=&quot;server&quot; ID=&quot;txtPhoneNumber&quot; /&gt;</pre></div></div>

<p>renders out as something like:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">	&lt;input type=&quot;text&quot; id=&quot;ctl00_ctl00_ctl00_main_Content_txtPhoneNumber&quot; 
		name=&quot;ctl00$ctl00$ctl00$main$Content$txtPhoneNumber&quot; /&gt;</pre></div></div>

<p>I <a href="http://lanitdev.wordpress.com/2009/06/08/extending-jquery-to-select-asp-controls/">did a write up</a> over on the <a href="http://lanitdev.wordpress.com/">LANIT development blog</a> about a solution to this problem using jQuery.</p>
<p>Check out the post for more details, but here is the function:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">	jQuery.<span style="color: #660066;">expr</span><span style="color: #009900;color: #000000;">&#91;</span><span style="color: #3366CC;color: #808080;">':'</span><span style="color: #009900;color: #000000;">&#93;</span>.<span style="color: #660066;">asp</span> <span style="color: #339933;color: #000000;">=</span> <span style="color: #003366; font-weight: bold;color: #0000FF;">function</span><span style="color: #009900;color: #000000;">&#40;</span>elem<span style="color: #339933;color: #000000;">,</span> i<span style="color: #339933;color: #000000;">,</span> match<span style="color: #009900;color: #000000;">&#41;</span> <span style="color: #009900;color: #000000;">&#123;</span>
		<span style="color: #000066; font-weight: bold;color: #0000FF;">return</span> <span style="color: #009900;color: #000000;">&#40;</span>elem.<span style="color: #660066;">id</span> <span style="color: #339933;color: #000000;">&amp;&amp;</span> elem.<span style="color: #660066;">id</span>.<span style="color: #660066;">match</span><span style="color: #009900;color: #000000;">&#40;</span>match<span style="color: #009900;color: #000000;">&#91;</span><span style="color: #CC0000;color: #808080;">3</span><span style="color: #009900;color: #000000;">&#93;</span> <span style="color: #339933;color: #000000;">+</span> <span style="color: #3366CC;color: #808080;">&quot;$&quot;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span>
	<span style="color: #009900;color: #000000;">&#125;</span><span style="color: #339933;color: #000000;">;</span>
&nbsp;
	$<span style="color: #009900;color: #000000;">&#40;</span><span style="color: #3366CC;color: #808080;">&quot;:asp(txtPhoneNumber)&quot;</span><span style="color: #009900;color: #000000;">&#41;</span>.<span style="color: #660066;">keyup</span><span style="color: #009900;color: #000000;">&#40;</span>...<span style="color: #009900;color: #000000;">&#41;</span><span style="color: #339933;color: #000000;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.briangrinstead.com/blog/extending-jquery-to-select-asp-controls/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

