<?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>Jquery &#124; Matthew Hailwood</title>
	<atom:link href="http://jquery.webspirited.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jquery.webspirited.com</link>
	<description>jQuery made me do it!</description>
	<lastBuildDate>Sun, 18 Nov 2012 06:35:43 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
<meta name="generator" content="deStyle 0.9.3" />
		<item>
		<title>Nifty Tricks: Setting a fallback source if an image fails to load.</title>
		<link>http://jquery.webspirited.com/2012/11/nifty-tricks-setting-fallback-source-image-fails-load/</link>
		<comments>http://jquery.webspirited.com/2012/11/nifty-tricks-setting-fallback-source-image-fails-load/#comments</comments>
		<pubDate>Sun, 18 Nov 2012 06:34:53 +0000</pubDate>
		<dc:creator>Matthew Hailwood</dc:creator>
				<category><![CDATA[Jquery]]></category>
		<category><![CDATA[Nifty Tricks]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://jquery.webspirited.com/?p=206</guid>
		<description><![CDATA[This useful little snippet allows you to set a backup source for an image if it fails to load. useful in a lot of situations, e.g. listing a directory contents, putting an image next to each item based on it&#8217;s extension using this code snippet if you do not have an image for a particular [...]]]></description>
			<content:encoded><![CDATA[<p>This useful little snippet allows you to set a backup source for an image if it fails to load. useful in a lot of situations, e.g. listing a directory contents, putting an image next to each item based on it&#8217;s extension using this code snippet if you do not have an image for a particular extension it will fall back to your default.</p>
<pre name="code" class="javascript">
var backup_src = 'http://domain.ext/images/backup.png';
var wanted_src = 'http://domain.ext/images/wanted.png';
var image = $('<img />'); //or point to an image that is already on the page!
image.on('error', function () {
    image.prop('src', backup_src);
});

image.prop('src', wanted_src);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jquery.webspirited.com/2012/11/nifty-tricks-setting-fallback-source-image-fails-load/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>#1 Crime of jQuery &#8211; DOM Abuse</title>
		<link>http://jquery.webspirited.com/2011/10/crime-of-jquery-_-dom-abuse/</link>
		<comments>http://jquery.webspirited.com/2011/10/crime-of-jquery-_-dom-abuse/#comments</comments>
		<pubDate>Sun, 30 Oct 2011 12:13:20 +0000</pubDate>
		<dc:creator>Matthew Hailwood</dc:creator>
				<category><![CDATA[Jquery]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://jquery.webspirited.com/?p=129</guid>
		<description><![CDATA[The Crime Here is an example, $(function(){ $('#id').change(function(){ //do stuff }); $('#id').css('border-color', '#ff0000'); var val = $('#id').val(); }); See what is happening here? There are several calls to $(&#8216;#id&#8217;). The reasoning Why is this so bad? Well, imagine the DOM as a giant pool of all elements on your page, every time you call $(&#8216;#id&#8217;) you [...]]]></description>
			<content:encoded><![CDATA[<h3>The Crime</h3>
<p>Here is an example,</p>
<pre class="javascript">$(function(){
  $('#id').change(function(){
    //do stuff
  });

  $('#id').css('border-color', '#ff0000');
  var val = $('#id').val();
});</pre>
<p>See what is happening here?<br />
There are several calls to <em>$(&#8216;#id&#8217;).</em></p>
<h3>The reasoning</h3>
<p>Why is this so bad?<br />
Well, imagine the DOM as a giant pool of all elements on your page, every time you call <em>$(&#8216;#id&#8217;)</em> you are diving into the pool and swimming around until you find the element you need. That adds some serious overhead on every call!<span id="more-129"></span></p>
<h3>The solution</h3>
<p>Caching!</p>
<pre class="javascript">$(function(){
  var element = $('#id'); //see what we are doing!
  element.change(function(){
    //do stuff
  });

  element.css('border-color', '#ff0000');
  var val = element.val();
});</pre>
<p>See what we have done here?<br />
We cut down our diving to only one call, keeping with the fish analogy think of it as, after storing the selector we now have it on a fishing rod, every time we want it we simply reel in the line and have our element!</p>
<p>Actually, There is one more thing we can do to improve this, method chaining!</p>
<pre class="javascript">$(function(){
  var element = $('#id'); //see what we are doing!
  element.change(function(){
    //do stuff
  }).css('border-color', '#ff0000');
  var val = element.val();
});</pre>
<p>Well, hopefully after reading this post you will no longer commit this crime, and pass this message along to anyone you know that commits this crime!</p>
]]></content:encoded>
			<wfw:commentRss>http://jquery.webspirited.com/2011/10/crime-of-jquery-_-dom-abuse/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery UI Widget Development Skeleton</title>
		<link>http://jquery.webspirited.com/2011/03/jquery-ui-widget-development-skeleton/</link>
		<comments>http://jquery.webspirited.com/2011/03/jquery-ui-widget-development-skeleton/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 05:50:53 +0000</pubDate>
		<dc:creator>Matthew Hailwood</dc:creator>
				<category><![CDATA[Jquery]]></category>
		<category><![CDATA[jQuery UI]]></category>
		<category><![CDATA[Widgets]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery ui]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://jquery.webspirited.com/?p=109</guid>
		<description><![CDATA[Quite often when I go to create a new widget I find myself clearing out all the old junk from another one of my widgets to try and create a skeleton, then go through and remember what the heck each part does, finally after 15 minutes I can create my widget! Well to solve this problem [...]]]></description>
			<content:encoded><![CDATA[<p>Quite often when I go to create a new widget I find myself clearing out all the old junk from another one of my widgets to try and create a skeleton, then go through and remember what the heck each part does, finally after 15 minutes I can create my widget!<br />
Well to solve this problem I have created a jQuery UI Widget Skeleton and I thought I should be nice and share it!<span id="more-109"></span></p>
<pre name="code" class="javascript">/*
 * First we start off with the closure
 * Notice that we pass in $ to the closure?
 * This is so that we can use $ as an alias to jQuery
 */
(function($) {

  /* First line defines the name of your widget */
  $.widget("ui.widgetName", {
    /*
     * Next line contains an object containing all the default options
     * that you want to use in your plugin
     */
    options: {},

    /*
     * Then we have the _create function
     * This function gets called as soon as your widget is invoked
     * Think of it as the initialization function.
     */
    _create: function() {

      /*
       * Its a good idea to store a reference to the object
       * That way you can reference "self" inside anything that changes
       * The scope of "this"
       *
       * "this" references the plugin instance
       * "this.element" references the dom element the widget was called on
       */
      var self = this;
    },

    /*
     * Next we can declare any private functions to be used internally by the widget
     * Although I'm not sure if jQuery does anything to protect these functions when
     * you prefix the name with an "_" it's not a bad design idea as you can instantly
     * recognize that the function is an internal function not to be called publicly
     */
    _myPrivateFunction: function() {
      /*
       * You can reference "this" in the same scope as "_create"
       * This function is designed to be called using "this._myPrivateFunction()"
       */
    },

    /*
     * Next we can declare any public functions to be called externally to modify or
     * interact with the widget. This is one of the most powerful features of the
     * jQuery UI Widget Factory
     */
    myPublicFunction: function() {
      /*
       * You can reference "this" in the same scope as "_create"
       * This function is designed to be called using "$('#elementId').widgetName('myPublicFunction')"
       */
    },

    /*
     * It is a good idea to write your own destroy function. The idea behind this is to remove any dom
     * changes you have made, or any variables you have left lying around.
     * jQuery will deal with removing the instance of the plugin.
     */
    destroy: function() {}
  });
  /*
   * Remember what I said in the first comment?
   * we pass in jQuery here so it gets aliased as $
   */
})(jQuery);</pre>
]]></content:encoded>
			<wfw:commentRss>http://jquery.webspirited.com/2011/03/jquery-ui-widget-development-skeleton/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery Tagit &#8211; A jQuery tagging plugin</title>
		<link>http://jquery.webspirited.com/2011/02/jquery-tagit-a-jquery-tagging-plugin/</link>
		<comments>http://jquery.webspirited.com/2011/02/jquery-tagit-a-jquery-tagging-plugin/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 06:07:39 +0000</pubDate>
		<dc:creator>Matthew Hailwood</dc:creator>
				<category><![CDATA[Jquery]]></category>
		<category><![CDATA[jQuery UI]]></category>
		<category><![CDATA[Widgets]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery ui]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://jquery.webspirited.com/?p=89</guid>
		<description><![CDATA[It depends on jQuery 1.4.2. and jQuery.ui 1.8 The <em>Jquery Tagit Plugin</em> transforms an html unordered list into a unique tagging plugin.<br />
Why unique? Because jQuery Tagit uses jQuery UI's auto-complete plugin to supply suggestions to users as they type and has some awesome features.]]></description>
			<content:encoded><![CDATA[<div><img style="float: left; margin: 0 5px 5px 0;" src="http://jquery.webspirited.com/publicscripts/tagit/preview.png" alt="jQuery Tagit Preview" /><br />
It depends on jQuery 1.4.2. and jQuery.ui 1.8 The <em>Jquery Tagit Plugin</em>transforms an html unordered list into a unique tagging plugin.Why unique? Because jQuery Tagit uses jQuery UI&#8217;s auto-complete plugin to supply suggestions to users as they type and has some awesome features.<span id="more-89"></span></p>
</div>
<div class="clear"></div>
<h2>Features</h2>
<ul>
<li>Convenient way for users to enter a list of items</li>
<li>Fully integrated with jQuery ui auto complete</li>
<li>Automatically adds current input as tag if input loses focus</li>
<li>Easy to use public methods</li>
<li>Easy to theme (single css file)</li>
<li>Customizable <em>accept</em> keys</li>
<li>Backspace on empty input deletes previous tag</li>
<li>Ability to provide <em>initial tags</em> on creation though options</li>
<li>Ability to provide <em>initial tags</em> on creation via list items</li>
<li>Option to toggle usage of a hidden select so the tags can be sent using a normal form!</li>
<li>Ability to sort tags via drag and drop!</li>
<li>Optional Themeroller Compatibility</li>
</ul>
<h2>Demo</h2>
<blockquote><p>Instead of a whole pile of blabing how about you just check out the <a class="vt-p" href="http://webspirited.com/tagit">demo</a>.</p></blockquote>
<p><a id="download-button" class="vt-p" href="https://github.com/hailwood/jQuery-Tagit">Download from <em>GitHub</em></a></p>
]]></content:encoded>
			<wfw:commentRss>http://jquery.webspirited.com/2011/02/jquery-tagit-a-jquery-tagging-plugin/feed/</wfw:commentRss>
		<slash:comments>99</slash:comments>
		</item>
		<item>
		<title>Jquery serializePost()</title>
		<link>http://jquery.webspirited.com/2011/02/jquery-serializepost/</link>
		<comments>http://jquery.webspirited.com/2011/02/jquery-serializepost/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 02:58:40 +0000</pubDate>
		<dc:creator>Matthew Hailwood</dc:creator>
				<category><![CDATA[Functions]]></category>
		<category><![CDATA[Jquery]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://jquery.webspirited.com/?p=74</guid>
		<description><![CDATA[jQuery has a couple of useful functions that you should be using quite a lot. .serialize() and .serializeArray(). These useful functions will take your form and spit out something you can send off in your ajax requests. &#8220;Awesome&#8221; you exclaim! &#8220;I&#8217;ll use it to send my post&#8220;. Not so fast! Turns out these functions are [...]]]></description>
			<content:encoded><![CDATA[<p>jQuery has a couple of useful functions that you should be using quite a lot. <a href="http://api.jquery.com/serialize/">.serialize()</a> and <a href="http://api.jquery.com/serializeArray/">.serializeArray()</a>.</p>
<p>These useful functions will take your form and spit out something you can send off in your ajax requests.<br />
<em>&#8220;Awesome&#8221;</em> you exclaim! <em>&#8220;I&#8217;ll use it to send my <span style="text-decoration: underline;">post</span>&#8220;</em>.</p>
<p>Not so fast!<br />
Turns out these functions are more or less useless for <span style="text-decoration: underline;">post</span> requests.<br />
That&#8217;s where this nifty little function comes in handy. call <code>$('form').serializePost()</code> on your form and it will serialize your post data and return a nice little javascript object ready to send off. On the other end you can access it as if you had submitted the form normally using <code>$_POST['myField']</code>.<span id="more-74"></span></p>
<pre class="javascript">(function($) {
    $.fn.serializePost = function() {
        var data = {};
        var formData = this.serializeArray();
        for (var i = formData.length; i--;) {
            var name = formData[i].name;
            var value = formData[i].value;
            var index = name.indexOf('[]');
            if (index &gt; -1) {
                name = name.substring(0, index);
                if (!(name in data)) {
                    data[name] = [];
                }
                data[name].push(value);
            }
            else
                data[name] = value;
        }
        return data;
    };
})(jQuery);</pre>
]]></content:encoded>
			<wfw:commentRss>http://jquery.webspirited.com/2011/02/jquery-serializepost/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Jquery &#8211; Color Picker</title>
		<link>http://jquery.webspirited.com/2010/12/jquery-color-picker/</link>
		<comments>http://jquery.webspirited.com/2010/12/jquery-color-picker/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 10:53:25 +0000</pubDate>
		<dc:creator>Matthew Hailwood</dc:creator>
				<category><![CDATA[Jquery]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://jquery.webspirited.com/?p=7</guid>
		<description><![CDATA[The <em>Jquery powered Color Picker</em> is styleable using a single stylesheet. It works in an <em>unobtrusive</em> fashion, by just turning html select inputs into a sexier equivalent. There's no extra markup needed.]]></description>
			<content:encoded><![CDATA[<div><img style="float: left; margin: 0 5px 5px 0;" src="http://jquery.webspirited.com/publicscripts/colorpicker/preview.png" alt="Color Picker Preview" /><br />
It depends on jQuery 1.4.2. The <em>Jquery powered Color Picker</em> is styleable using a single stylesheet. It works in an <em>unobtrusive</em> fashion, by just turning html select inputs into a sexier equivalent. There&#8217;s no extra markup needed.<span id="more-7"></span>If javascript is not enabled the normal html select is still displayed meaning it is <em>compatable</em> with all browsers.</p>
<div class="clear-block"></div>
</div>
<p>On many a website to select a color you are given a html select box with a list of color names, or hex values.</p>
<blockquote><p>Something like this</p>
<select>
<option value="FFFFFF">FFFFFF</option>
<option value="FFDFDF">FFDFDF</option>
<option value="FFBFBF">FFBFBF</option>
<option value="FF9F9F">FF9F9F</option>
<option value="FF7F7F">FF7F7F</option>
<option value="FF5F5F">FF5F5F</option>
<option value="FF3F3F">FF3F3F</option>
<option value="FF1F1F">FF1F1F</option>
<option value="FF0000">FF0000</option>
<option value="DF1F00">DF1F00</option>
<option value="C33B00">C33B00</option>
<option value="A75700">A75700</option>
<option value="8B7300">8B7300</option>
<option value="6F8F00">6F8F00</option>
<option value="53AB00">53AB00</option>
<option value="37C700" selected="selected">37C700</option>
<option value="1BE300">1BE300</option>
<option value="00FF00">00FF00</option>
<option value="00DF1F">00DF1F</option>
<option value="00C33B">00C33B</option>
<option value="00A757">00A757</option>
<option value="008B73">008B73</option>
<option value="006F8F">006F8F</option>
<option value="0053AB">0053AB</option>
<option value="0037C7">0037C7</option>
<option value="001BE3">001BE3</option>
<option value="0000FF">0000FF</option>
<option value="0000df">0000df</option>
<option value="0000c3">0000c3</option>
<option value="0000a7">0000a7</option>
<option value="00008b">00008b</option>
<option value="00006f">00006f</option>
<option value="000053">000053</option>
<option value="000037">000037</option>
<option value="00001b">00001b</option>
<option value="000000">000000</option>
</select>
</blockquote>
<p>This is both unintuitive and downright ugly. My thinking was that there has to be a better way. And thats where the <em>Jquery Color Picker</em> comes in.</p>
<p>The big difference between the <em>Jquery Color Picker</em> and <a href="http://www.eyecon.ro/colorpicker/">other Jquery powered color pickers</a> is the <em>Jquery Color Picker</em> takes a normal html select like above and turns it into an intuitive, cross browser, color picker.</p>
<p>This allows you to control the colors that can be picked, and send the chosen value through a form without having to manipulate the output.</p>
<h2>Demo</h2>
<blockquote><p>Normally the select element is hidden, for the demo we have shown it.</p>
<select id="picker">
<option value="FFFFFF">FFFFFF</option>
<option value="FFDFDF">FFDFDF</option>
<option value="FFBFBF">FFBFBF</option>
<option value="FF9F9F">FF9F9F</option>
<option value="FF7F7F">FF7F7F</option>
<option value="FF5F5F">FF5F5F</option>
<option value="FF3F3F">FF3F3F</option>
<option value="FF1F1F">FF1F1F</option>
<option value="FF0000">FF0000</option>
<option value="DF1F00">DF1F00</option>
<option value="C33B00">C33B00</option>
<option value="A75700">A75700</option>
<option value="8B7300">8B7300</option>
<option value="6F8F00">6F8F00</option>
<option value="53AB00">53AB00</option>
<option value="37C700" selected="selected">37C700</option>
<option value="1BE300">1BE300</option>
<option value="00FF00">00FF00</option>
<option value="00DF1F">00DF1F</option>
<option value="00C33B">00C33B</option>
<option value="00A757">00A757</option>
<option value="008B73">008B73</option>
<option value="006F8F">006F8F</option>
<option value="0053AB">0053AB</option>
<option value="0037C7">0037C7</option>
<option value="001BE3">001BE3</option>
<option value="0000FF">0000FF</option>
<option value="0000df">0000df</option>
<option value="0000c3">0000c3</option>
<option value="0000a7">0000a7</option>
<option value="00008b">00008b</option>
<option value="00006f">00006f</option>
<option value="000053">000053</option>
<option value="000037">000037</option>
<option value="00001b">00001b</option>
<option value="000000">000000</option>
</select>
</blockquote>
<pre name="code" class="javascript">
&lt;select id=&quot;picker&quot;&gt;&#10;&lt;option value=&quot;FFFFFF&quot;&gt;FFFFFF&lt;/option&gt;&#10;&lt;option value=&quot;FFDFDF&quot;&gt;FFDFDF&lt;/option&gt;&#10;...&#10;&lt;option value=&quot;00001b&quot;&gt;00001b&lt;/option&gt;&#10;&lt;option value=&quot;000000&quot;&gt;000000&lt;/option&gt;&#10;&lt;/select&gt;&#10;&lt;link rel=&quot;stylesheet&quot; href=&quot;jquery.colorpicker.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt; &#10;&lt;script src=&quot;jquery.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&#10;&lt;script src=&quot;jquery.colorpicker.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&#10;&lt;script type=&quot;text/javascript&quot;&gt;&#10;$(document).ready(function(){&#10;    $(&#39;#picker&#39;).colorpicker({&#10;        size: 20,&#10;        label: &#39;Color: &#39;,&#10;        hide: false&#10;    });&#10;});&#10;&lt;/script&gt;
</pre>
<h2>Options</h2>
<table style="width:100%">
<thead>
<tr>
<th> Parameter</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td>size</td>
<td>Size in px of the color squares</td>
<td>20</td>
</tr>
<tr>
<td>scount</td>
<td>How many color squares to show per row</td>
<td>6</td>
</tr>
<tr>
<td>label</td>
<td>A label to prepend to the picker</td>
<td>Color: </td>
</tr>
<tr>
<td>hide</td>
<td>should the original <em>select</em> be hidden?</td>
<td>false</td>
</tr>
</tbody>
</table>
<p><a href="https://github.com/hailwood/jQuery-Color-Picker" id="download-button">Download from <em>GitHub</em></a></p>
<link rel="stylesheet" href="http://jquery.webspirited.com/publicscripts/colorpicker/jquery.colorpicker.css" type="text/css" media="screen" />
<script src="http://code.jquery.com/jquery-latest.pack.js" type="text/javascript"></script><br />
<script src="http://jquery.webspirited.com/publicscripts/colorpicker/jquery.colorpicker.js" type="text/javascript"></script><br />
<script type="text/javascript">
$(document).ready(function(){
    $('#picker').colorpicker({
        size: 20,
        label: 'Color: ',
        hide: false
    });
});
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://jquery.webspirited.com/2010/12/jquery-color-picker/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
	</channel>
</rss>
