<?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>WGO &#187; jQuery</title>
	<atom:link href="http://www.wiseguysonly.com/category/web-development/javascript/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wiseguysonly.com</link>
	<description>Tim Roberts CakePHP, MySQL and jQuery Developer</description>
	<lastBuildDate>Thu, 02 Feb 2012 19:22:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Select and Unselect All Checkboxes with jQuery</title>
		<link>http://www.wiseguysonly.com/2010/01/15/select-and-unselect-all-checkboxes-with-jquery/</link>
		<comments>http://www.wiseguysonly.com/2010/01/15/select-and-unselect-all-checkboxes-with-jquery/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 19:01:06 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[User Interface]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.wiseguysonly.com/?p=308</guid>
		<description><![CDATA[I&#8217;ve been working with jQuery to spice up my interfaces for over 12 months now and figured it&#8217;s time to share some of the little techniques I&#8217;ve developed on the way. The first is something I use quite alot when I am giving users the ability to administer lists of items in bulk. That including [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working with jQuery to spice up my interfaces for over 12 months now and figured it&#8217;s time to share some of the little techniques I&#8217;ve developed on the way.</p>
<p>The first is something I use quite alot when I am giving users the ability to administer lists of items in bulk. That including a checkbox that when checked sets the state of all the checkboxes beside a list of items to &#8220;checked&#8221;. Naturally unchecking it will uncheck all checkboxes. I&#8217;m sure you get the picture here&#8217;s the code based on two scenarios depending on your preference. But firstly you need to include the jQuery library in the head of your document (I grab mine straight from Google&#8217;s repository to save my bandwidth):</p>
<p><span id="more-308"></span></p>
<p><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;</code></p>
<p>and then somewhere in your document a controller checkbox that toggles all the others (note the call to toggleChecked when the state of the checkbox changes):</p>
<p><code>&lt;input type="checkbox" onclick="toggleChecked(this.checked)"&gt; Select / Deselect All</code></p>
<p>Now here are  two versions of the toggleChecked function dependent on the semantics of your document. The only real difference is the jQuery selector for your list checkboxes:</p>
<p><strong>1: All checkboxes have a class of  &#8220;checkbox&#8221; (&lt;input type=&#8221;checkbox&#8221; class=&#8221;checkbox&#8221; /&gt;)</strong><br />
<code>function toggleChecked(status) {<br />
$(".checkbox").each( function() {<br />
$(this).attr("checked",status);<br />
})<br />
}</code></p>
<p><strong>2: All the checkboxes are contained within a div with an arbitary id:</strong></p>
<p><code>&lt;div id="checkboxes"&gt;<br />
&lt;input type="checkbox" /&gt;<br />
&lt;input type="checkbox" /&gt;<br />
&lt;input type="checkbox" /&gt;<br />
&lt;/div&gt;</code></p>
<p>In this case the function would look like this:</p>
<p><code>function toggleChecked(status) {<br />
$("#checkboxes input").each( function() {<br />
$(this).attr("checked",status);<br />
})<br />
</code></p>
<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wiseguysonly.com/2010/01/15/select-and-unselect-all-checkboxes-with-jquery/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Thickbox, accessibility and search engine optimisation.</title>
		<link>http://www.wiseguysonly.com/2009/02/22/thickbox-accessibility-and-search-engine-optimisation/</link>
		<comments>http://www.wiseguysonly.com/2009/02/22/thickbox-accessibility-and-search-engine-optimisation/#comments</comments>
		<pubDate>Sun, 22 Feb 2009 10:21:09 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.wiseguysonly.com/?p=205</guid>
		<description><![CDATA[Recently I noticed that whilst my new project the Vietnam War Timeline was organically racing up the search engines, through virtue of being in a niche and growing daily in content, the bounce rate was exceptionally high. A lot of traffic was coming in but not venturing beyond the entry page. After a very quick [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I noticed that whilst my new project the <a href="http://www.vietnam-timeline.com">Vietnam War Timeline</a> was organically racing up the search engines, through virtue of being in a niche and growing daily in content, the bounce rate was exceptionally high. A lot of traffic was coming in but not venturing beyond the entry page.</p>
<p>After a very quick investigation it became apparent why this was: all links off the timeline fire a new <a href="http://jquery.com/demo/thickbox/">Thickbox</a> window with the relevant content. It&#8217;s a nice way to keep people within the timeline when they need to look at more content. Moreover, it&#8217;s unobtrusive, meaning the links can just be followed as normal by non-javascript enabled browsers.<span id="more-205"></span></p>
<p>However, therein lies the issue of the exceptional bounce rate.</p>
<p>The Thickbox pages are all indexed well by the search engines. Indeed, as they often hold the relevant content, they figure higher than the home page itself for many searches. But these individual pages are devoid of navigation and are singletons in the sense that they give no indication of more related information being available.  In SEO terms they are <em>orphaned pages</em> and in real user terms they offer no way for the user to investigate more of the site.</p>
<p>You&#8217;re probably ahead of me with a solution here; it&#8217;s a pretty simple one:</p>
<ol>
<li>include navigation in all content;</li>
<li>if the content is opened by Thickbox, destroy the navigation.</li>
</ol>
<p>In the iframed page the following Javascript achieves this:</p>
<p>&lt;script&gt;<br />
if(typeof parent.tb_remove == &#8216;function&#8217;) {<br />
document.getElementById(&#8220;nav&#8221;).style.display=&#8221;none&#8221;;<br />
}<br />
&lt;/script&gt;</p>
<p>This conditional statement checks the parent window for a function called tb_remove (the function that closes thickbox). If this evaluates to true we can use any dom selectors we like to hide page elements we don&#8217;t want to show. If the iframed page is accessed directly either by a real user or a search engine, the navigation will not be destroyed and the page will no longer be orphaned.</p>
<p>See it in action by accessing the first item from the <a href="http://www.vietnam-timeline.com">Vietnam War Timeline &#8211; May 7th &#8211; French defeated at the battle of Dien Bien Phu</a> and then <a href="http://www.vietnam-timeline.com/vietnam-war-event_18_french-defeated-at-the-battle-of-dien-bien-phu?KeepThis=true&amp;TB_iframe=true&amp;height=400&amp;width=600">try accessing the same page directly</a>.</p>
<p>A small price to pay for added SEO and usability in Thickbox.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wiseguysonly.com/2009/02/22/thickbox-accessibility-and-search-engine-optimisation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Drag and drop reordering of database fields (sortables) with jQuery</title>
		<link>http://www.wiseguysonly.com/2008/12/07/drag-and-drop-reordering-of-database-fields-sortables-with-jquery/</link>
		<comments>http://www.wiseguysonly.com/2008/12/07/drag-and-drop-reordering-of-database-fields-sortables-with-jquery/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 18:21:17 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[User Interface]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.wiseguysonly.com/?p=143</guid>
		<description><![CDATA[This tutorial explains how to display a list of items from a database that can be reordered in real time by dragging and dropping, using the jQuery library. Moreover, no page reload is required on every reorder. If you want a bigger introduction to why you may want to do this I suggest reading my [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial explains how to display a list of items from a database that can be reordered in real time by dragging and dropping, using the jQuery library. Moreover, no page reload is required on every reorder. If you want a bigger introduction to why you may want to do this I suggest reading my tutorial on <a href="/2006/08/11/drag-and-drop-reordering-of-database-fields-with-ajax/">how to achieve the same functionality using scriptaculous</a>.</p>
<p>Previously I have explained how to achieve this in <a href="/2006/08/11/drag-and-drop-reordering-of-database-fields-with-ajax/">Scriptaculous</a> and <a href="/2007/10/10/drag-and-drop-reordering-of-database-fields-sortables-with-mootools/">Mootools</a>.</p>
<p><span id="more-143"></span></p>
<p><strong>Step one: Include the jQuery libraries.</strong></p>
<p>Grab <a href="http://docs.jquery.com/Downloading_jQuery">jQuery</a> and <a href="http://ui.jquery.com/download_builder/">jQuery UI</a> libraries.</p>
<p>Include them in the head of your document:<br />
<code>&lt;<span class="start-tag">script</span><span class="attribute-name"> type</span>=<span class="attribute-value">"text/javascript" </span><span class="attribute-name">src</span>=<span class="attribute-value">"javascripts/jquery-1.2.6.min.js"</span>&gt;&lt;/<span class="end-tag">script</span>&gt;<br />
&lt;<span class="start-tag">script</span><span class="attribute-name"> type</span>=<span class="attribute-value">"text/javascript" </span><span class="attribute-name">src</span>=<span class="attribute-value">"javascripts/jquery-ui-personalized-1.5.2.min.js"</span>&gt;&lt;/<span class="end-tag">script</span>&gt;</code></p>
<p><strong>Step two: Build a list of items from the database.</strong></p>
<p>Give your list and id &#8211; I am using item_list for this tutorial &#8211; and then make sure each list item has an id of &#8220;item_PRIMARYKEY&#8221; where PRIMARYKEY is the key of the item from the database. Here is something similar to the list you should have:</p>
<p><code><br />
&lt;ul id="item_list" &gt;<br />
&lt;li id="item_1"&gt;Item One&lt;/li&gt;<br />
&lt;li id="item_2"&gt;Item Two&lt;/li&gt;<br />
&lt;li id="item_3"&gt;Item Three&lt;/li&gt;<br />
&lt;li id="item_4"&gt;Item Four&lt;/li&gt;<br />
&lt;/ul&gt;</code></p>
<p><strong>Step 3: Make the list sortable and add a callback to our database script.</strong></p>
<p>Using jQuery&#8217;s onload function or by adding the following script below our list,  inject some javascript into our list to make the list items sortable</p>
<p><code> $("#item_list").sortable({stop:function(i) {<br />
$.ajax({<br />
type: "GET",<br />
url: "server_items_reorder.php",<br />
data: $("#item_list").sortable("serialize")<br />
});</code></p>
<p>Let&#8217;s look at this line by line so you can understand what is happening.</p>
<p>Line one uses the jQuery selector to target the element with an id of item_list (our unordered list in this case). We then apply the sortable plugin from jQuery UI.</p>
<p><a href="http://docs.jquery.com/UI/Sortable/sortable#options">Sortable has a number of options available</a>, but in this case we are going to use the stop option (when sorting has finished) to make an ajax call. The important options in our ajax call are as follows:</p>
<ul>
<li>type: the type of call (in this case GET);</li>
<li>url: (where the ajax post should be made) in this case &#8220;server_items_reorder.php&#8221;;</li>
<li>data : the string the makes up our GET call;</li>
</ul>
<p>The data can be easily built up by using more of the inbuilt functionality of jQuery&#8217;s sortable:</p>
<p><code>$("#item_list").sortable("serialize")</code></p>
<p>This takes the current order of our list and builds it into an array that can be passed on like a GET string:</p>
<p>item[]=1&amp;item[]=2&amp;item[]=3&amp;item[]=4</p>
<p>jQuery automatically serializes the list item id&#8217;s  into this array so you can see why I chose to give them the id item_PRIMARYKEY for the ease offered by convention.</p>
<p>So now we are making a ajax call and padding on the new list order we can write a script to update the database.</p>
<p><strong>Step four: The database script (updating the position).</strong></p>
<p>I am assuming your database table has an extra field called &#8220;position&#8221; that you can use to hold an integer of each items position as relating to its peers. What we need to do now is create our server_items_reorder.php script to collect the array of items and update the database. Here is that script:</p>
<p><code>// YOUR DB CONNECTION HERE<br />
foreach($_GET['item'] as $key=&gt;$value) {<br />
mysql_query("UPDATE my_items" SET position = '" . $key . "' WHERE id ='" . $value . "'");<br />
}</code></p>
<p>This script is simple enough to be written in the language of your choice. It collects the array of items from the GET variable and for each one updates the position based on the id of the item.</p>
<p>That&#8217;s all there is to it.</p>
<p>This tutorial is pretty low level as I have written most of these concepts including troubleshooting in my  <a href="/2006/08/11/drag-and-drop-reordering-of-database-fields-with-ajax/">Scriptaculous</a> and <a href="/2007/10/10/drag-and-drop-reordering-of-database-fields-sortables-with-mootools/">Mootools</a> versions of these, so if you experience any difficulties look at those tutorials first, read the user comments and/or post any questions here.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wiseguysonly.com/2008/12/07/drag-and-drop-reordering-of-database-fields-sortables-with-jquery/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>jQuery table effects plugin &#8211; v1.0</title>
		<link>http://www.wiseguysonly.com/2008/10/12/jquery-table-effects-plugin-v10/</link>
		<comments>http://www.wiseguysonly.com/2008/10/12/jquery-table-effects-plugin-v10/#comments</comments>
		<pubDate>Sun, 12 Oct 2008 12:58:38 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[User Interface]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://wiseguysonly.com/?p=78</guid>
		<description><![CDATA[See the demo here. My first outing into producing a jQuery plugin is the limited, but useful “jQuery table effects”. The current version defines the following features: Alternating row colours for readability (striping). onmouseover and onmouseout events for manipulating the background colour of the row. Requirements: jQuery 1.25+ jtable-effects: minified (1kb) &#124; source(1kb) Optional complete [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://wiseguysonly.com/demos/jquery/table-effects-jquery.html"><strong>See the demo here</strong></a>.</p>
<p>My first outing into producing a jQuery plugin is the limited, but useful “jQuery table effects”.</p>
<p>The current version defines the following features:</p>
<ol>
<li>Alternating row colours for readability (striping).</li>
<li>onmouseover and onmouseout events for manipulating the background colour of the row.</li>
</ol>
<p><span id="more-78"></span></p>
<p><strong>Requirements:</strong></p>
<ul>
<li><a href="http://docs.jquery.com/Downloading_jQuery#Download_jQuery">jQuery 1.25+</a></li>
<li>jtable-effects: <a href="../demos/jquery/javascripts/jtable-1.0.min.js">minified (1kb)</a> | <a href="../demos/jquery/javascripts/jtable-1.0.js">source(1kb)<br />
</a></li>
<li><a href="../demos/jquery/table-effects-jquery.zip">Optional complete package of demo files (19kb)</a>.</li>
</ul>
<p><strong>Implementation</strong>:</p>
<p>Include the jQuery library and the jtable-effects plugin in the head of your document:</p>
<p><code>&lt;<span class="start-tag">script</span><span class="attribute-name"> type</span>=<span class="attribute-value">“text/javascript” </span><span class="attribute-name">src</span>=<span class="attribute-value">“javascripts/jquery-1.2.6.min.js”</span>&gt;&lt;/<span class="end-tag">script</span>&gt;<br />
&lt;<span class="start-tag">script</span><span class="attribute-name"> type</span>=<span class="attribute-value">“text/javascript” </span><span class="attribute-name">src</span>=<span class="attribute-value">“javascripts/jtable-1.0.min.js”</span>&gt;&lt;/<span class="end-tag">script</span>&gt;</code></p>
<p>Then call the jTable function for each instance of a table you wish to maniuplate &#8211; do this using the onload functionality of jQuery:</p>
<p><code>&lt;<span class="start-tag">script</span><span class="attribute-name"> type</span>=<span class="attribute-value">“text/javascript”</span>&gt;<br />
$(document).ready(function(){<br />
jTable(”demo-table”,{stripe:’#EED’,over:’#FC0′,out:’#FFF’});<br />
});<br />
&lt;/<span class="end-tag">script</span>&gt;</code></p>
<p id="line1">The first argument is the id of the table body (tbody) to apply the effects to and the second is an array of options available:</p>
<ul>
<li><em>stripe: </em>defines the html colour reference for alternating rows. (hex or rgb).</li>
<li><em>over:</em> defines the html colour reference for mouseover. (hex or rgb).</li>
<li><em>out:</em> defines the html colour reference for mouseout &#8211; this has no effect on the striped rows which return to the value defined by <em>stripe</em>. (hex or rgb).</li>
</ul>
<p>Finally, <a href="http://wiseguysonly.com/demos/jquery/table-effects-jquery.html">a demonstration of jtable effects 1.0</a> can be seen here and<a href="../demos/jquery/table-effects-jquery.zip"> a set of demo files can be downloaded here (19kb)</a>.</p>
<p>Please post comments, support requests, bug reports and feature requests for v1.1 in the comments here</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wiseguysonly.com/2008/10/12/jquery-table-effects-plugin-v10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

