<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>Brian Swartzfager&apos;s Blog - jQuery</title>
			<link>http://www.swartzfager.org/blog/index.cfm</link>
			<description>blog</description>
			<language>en-us</language>
			<pubDate>Fri, 03 Sep 2010 12:39:05 -0400</pubDate>
			<lastBuildDate>Mon, 25 May 2009 14:55:00 -0400</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>bcswartz@gmail.com</managingEditor>
			<webMaster>bcswartz@gmail.com</webMaster>
			
			<item>
				<title>My First Mozilla Jetpack Add-On For Firefox: browseTimer</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2009/5/25/My-First-Mozilla-Jetpack-AddOn-For-Firefox-browseTimer</link>
				<description>
				
				As I &lt;a href=&quot;http://www.swartzfager.org/blog/index.cfm/2009/5/21/Mozilla-Announceds-Jetpack-an-API-For-Writing-FireFox-AddsOn-with-jQuery-HTML-and-CSS&quot; target=&quot;_blank&quot;&gt;previously mentioned&lt;/a&gt; on my blog last week, Mozilla has launched a new means of creating add-ons for Firefox called &lt;a href=&quot;https://jetpack.mozillalabs.com/&quot; target=&quot;_blank&quot;&gt;Jetpack&lt;/a&gt;, which allows would-be plugin developers to build add-ons with HTML, CSS, and Javascript functions that include all of the &lt;a href=&quot;http://www.jquery.com&quot; target=&quot;_blank&quot;&gt;jQuery&lt;/a&gt; functions.

As it happens, the first two functions listed in the &lt;a href=&quot;https://jetpack.mozillalabs.com/api.html&quot; target=&quot;_blank&quot;&gt;Jetpack API&lt;/a&gt; were the &lt;em&gt;clearInterval()&lt;/em&gt; and &lt;em&gt;clearTimeout()&lt;/em&gt; functions, and that gave me a idea.  My most recent AIR application, &lt;a href=&quot;http://focustimer.riaforge.org&quot; target=&quot;_blank&quot;&gt;focusTimer&lt;/a&gt;, is a desktop widget inspired by time management techniques like &lt;a href=&quot;http://www.pomodorotechnique.com/&quot; target=&quot;_blank&quot;&gt;Pomodoro&lt;/a&gt;, where you basically shut out/off all distractions and work on a task for a set amount of time.  Once that time is up, the idea is to take a short break before starting another distraction-free period.

&lt;img src=&quot;http://www.swartzfager.org/blog/mozillaJetpack/browseTimer/screenshot.gif&quot; style=&quot;padding: 5px 15px; float: right;&quot;&gt; 

So my Jetpack add-on, &lt;a href=&quot;http://www.swartzfager.org/blog/mozillaJetpack/browseTimer/installBrowseTimer.html&quot; target=&quot;_blank&quot;&gt;browseTimer&lt;/a&gt;, is a timer built into the status bar of Firefox that lets you set how much time you want to spend browsing the web before getting back to work.  Once the timer expires, the add-on uses the Jetpack API functions for the Firefox tabs to blank out the content of all of your open Firefox tabs and turn the body of the now-blank pages red (in other words, you KNOW when the timer has run out!).

It&apos;s certainly not the most useful add-on in the world, but it didn&apos;t take long and it helped me learn the basics of Jetpack.

If you&apos;re interested in checking it out, visit the following page...

&lt;a href=&quot;http://www.swartzfager.org/blog/mozillaJetpack/browseTimer/installBrowseTimer.html&quot; target=&quot;_blank&quot;&gt;http://www.swartzfager.org/blog/mozillaJetpack/browseTimer/installBrowseTimer.html&lt;/a&gt;

...for the link to the Jetpack add-on need to run all Jetpack-based add-ons, links to the Macintosh and Windows versions (there were slight differences in how the input elements were displayed in the status bar that warranted two separate versions), and instructions on how to uninstall it if you don&apos;t like it/need it. 
				</description>
				
				<category>Miscellaneous</category>
				
				<category>jQuery</category>
				
				<category>JavaScript</category>
				
				<pubDate>Mon, 25 May 2009 14:55:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2009/5/25/My-First-Mozilla-Jetpack-AddOn-For-Firefox-browseTimer</guid>
				
			</item>
			
			<item>
				<title>Mozilla Announces Jetpack, an API For Writing FireFox Adds-On with jQuery, HTML, and CSS</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2009/5/21/Mozilla-Announceds-Jetpack-an-API-For-Writing-FireFox-AddsOn-with-jQuery-HTML-and-CSS</link>
				<description>
				
				I found out about this last night from a tweet sent out by the &lt;a href=&quot;http://www.twitter.com/jquery&quot; target=&quot;_blank&quot;&gt;jQuery Twitter account&lt;/a&gt; (which is probably a good indication that they like the idea).

The subject line pretty much says it all:  Jetpack is designed to let current web developers use their existing skills with HTML, CSS, JavaScript, and jQuery to build Firefox add-ons/plugins without the need to mess with Firefox&apos;s XUL mark-up language.  While JavaScript has always been part of the add-on development process, the inclusion of jQuery should make performing certain actions a whole lot easier.

You can learn more about Jetpack via the following URLs:

&lt;ul&gt;
&lt;li&gt;
&lt;a href=&quot;https://jetpack.mozillalabs.com/&quot; target=&quot;_blank&quot;&gt;https://jetpack.mozillalabs.com/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&quot;http://labs.mozilla.com/2009/05/introducing-jetpack-call-for-participation/&quot; target=&quot;_blank&quot;&gt;http://labs.mozilla.com/2009/05/introducing-jetpack-call-for-participation/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&quot;https://jetpack.mozillalabs.com/tutorial.html&quot; target=&quot;_blank&quot;&gt;https://jetpack.mozillalabs.com/tutorial.html&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

...the tutorials in the final link give you a good idea of the kinds of things Jetpack will allow you to do:  the last example is a Jetpack add-on that will count and display the number of unread e-mails in your Gmail Inbox.

I want to give Jetpack a whirl, but I honestly can&apos;t think of any functionality I want to add to Firefox that I can&apos;t get from an existing plugin.  Anyone have any suggestions for something to try with Jetpack? 

It&apos;s interesting how web technologies keep being repurposed as a development option in other technologies (Adobe AIR, the upcoming Palm Pre&apos;s &lt;a href=&quot;http://developer.palm.com/&quot; target=&quot;_blank&quot;&gt;WebOS&lt;/a&gt;, and now Jetpack).  Even though I&apos;m not particularly interested in delving into all these different areas, I must say that I like the trend.  :) 
				</description>
				
				<category>RIAs</category>
				
				<category>Miscellaneous</category>
				
				<category>jQuery</category>
				
				<category>JavaScript</category>
				
				<category>CSS</category>
				
				<pubDate>Thu, 21 May 2009 07:29:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2009/5/21/Mozilla-Announceds-Jetpack-an-API-For-Writing-FireFox-AddsOn-with-jQuery-HTML-and-CSS</guid>
				
			</item>
			
			<item>
				<title>Using jQuery Manipulation Functions (Append, Prepend, After, Before) To Reorder Items</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2009/3/25/Using-jQuery-Manipulation-Functions-Append-Prepend-After-Before-To-Reorder-Items</link>
				<description>
				
				I discovered something interesting quite by accident today.  I was trying to figure out the best way to reorder certain &amp;lt;li&amp;gt; items based on the value of a particular trait (while ignoring those &amp;lt;li&amp;gt; items that didn&apos;t have that particular trait at all).  I figured the best way to accomplish this was to:
&lt;ol&gt;
&lt;li&gt;Select all of the items that had the trait and store them in an array&lt;/li&gt;
&lt;li&gt;Resort the contents of the array into a new array.&lt;/li&gt;
&lt;li&gt;Delete the selected items from the list (so as not to replicate them)&lt;/li&gt;
&lt;li&gt;Loop through the new array and add the items back into the list using the jQuery &lt;strong&gt;prepend()&lt;/strong&gt; function to put them at the top of the list.&lt;/li&gt;
&lt;/ol&gt;

When I ran my first test of my code, I left out the deletion step so I could compare the original item order with the new item order, figuring I would have duplicates of the selected items.

However, I was surprised to discover that &lt;strong&gt;prepend()&lt;/strong&gt; removed the original instances of the selected list items, leaving only the prepended copies.  Essentially, it ended up moving the items rather than duplicating them.  

There&apos;s nothing on the official documentation page that says that if you&apos;re prepending an item to a collection that already contains an instance of that item that it will remove the original item for you, but that&apos;s apparently what it&apos;s programmed to do.

I ran a quick test of some of the other related Manipulation functions (&lt;strong&gt;append()&lt;/strong&gt;,&lt;strong&gt;after()&lt;/strong&gt;,&lt;strong&gt;before()&lt;/strong&gt;), and they all seem to behave that way as well.

Thought it was worth sharing.  Certainly makes my reordering task a bit easier. 
				</description>
				
				<category>jQuery</category>
				
				<category>JavaScript</category>
				
				<pubDate>Wed, 25 Mar 2009 13:19:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2009/3/25/Using-jQuery-Manipulation-Functions-Append-Prepend-After-Before-To-Reorder-Items</guid>
				
			</item>
			
			<item>
				<title>Using jQuery UI Sortables To Move Items From One List To Another</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2009/3/20/Using-jQuery-UI-Sortables-To-Move-Items-From-One-List-To-Another</link>
				<description>
				
				During my most recent project, my clients asked me to build a web-based tool that would help them place volunteers into various standing committees.  Placements would be made based on the preferences of the volunteers (who were asked to choose up to three committees they would like to serve on), the vacancies created in each committee by outgoing members, and the desire to have a diversity of units and divisions represented in each committee.

I decided pretty quickly that the most natural way to represent this placement process on a web page would be to let them &quot;physically&quot; move a volunteer into a committee.  I had built similar tools before (even before I started using jQuery), but never with more than two lists or collections, so I went to the &lt;a href=&quot;http://jqueryui.com/&quot; target=&quot;_blank&quot;&gt;jQuery UI site&lt;/a&gt; to see what my options were.

I started with the most obvious place to start, the &lt;a href=&quot;http://jqueryui.com/demos/droppable/&quot; target=&quot;_blank&quot;&gt;Droppable&lt;/a&gt; interaction, but soon realized that a better choice for this task was the &lt;a href=&quot;http://jqueryui.com/demos/sortable/&quot; target=&quot;_blank&quot;&gt;Sortables&lt;/a&gt; interaction.

The primary focus of the Sortable interaction is to let you reorder a collection of DOM elements by dragging them up-and-down through the collection.  It&apos;s extremely easy to implement in its most basic form.  If you wanted to make all of the &amp;lt;li&amp;gt; elements in a &amp;lt;ul&amp;gt; with an &quot;id&quot; attribute &quot;listA&quot; sortable, you can do it in one line:

&lt;p style=&quot;background-color:#ffffcc;padding:10px;&quot;&gt;
$(document).ready() {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;$(&quot;#listA&quot;).sortable();&lt;br /&gt;
});&lt;br /&gt;
&lt;/p&gt;


...you can see that code in action on the home page of the &lt;a href=&quot;http://jqueryui.com/demos/sortable/&quot; target=&quot;_blank&quot;&gt;Sortables&lt;/a&gt; interaction.

What I discovered was that it was almost as easy to connect one Sortable list to another, so that in addition to being able to move reorder items within each list, you could &lt;strong&gt;drag items from one list to the other&lt;/strong&gt;, simply by using the &quot;connectWith&quot; option:

&lt;p style=&quot;background-color:#ffffcc;padding:10px;&quot;&gt;
$(document).ready() {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;$(&quot;#listA&quot;).sortable({&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;connectWith: [&apos;#listB&apos;]&lt;/strong&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;});&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;$(&quot;#listB&quot;).sortable({&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;connectWith: [&apos;#listA&apos;]&lt;/strong&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;});&lt;br /&gt;
});
&lt;/p&gt;

...In the code above, the first sortable() function call makes &lt;strong&gt;listA&lt;/strong&gt; sortable and uses the &quot;connectWith&quot; option to allow items from &lt;strong&gt;listA&lt;/strong&gt; to be dragged into &lt;strong&gt;listB&lt;/strong&gt;.  The second sortable() function call lets you sort items in &lt;strong&gt;listB&lt;/strong&gt; and drag items from &lt;strong&gt;listB&lt;/strong&gt; over to &lt;strong&gt;listA&lt;/strong&gt; (even items that originally belonged to &lt;strong&gt;listA&lt;/strong&gt;).  If you wanted the movement to only go in one direction (from &lt;strong&gt;listA&lt;/strong&gt; to &lt;strong&gt;listB&lt;/strong&gt; but not back again), you could leave out the &quot;connectWith&quot; option for &lt;strong&gt;listB&lt;/strong&gt;.

Again, the jQuery UI site has a nice &lt;a href=&quot;http://jqueryui.com/demos/sortable/#connect-lists&quot; target=&quot;_blank&quot;&gt;ready-made demo&lt;/a&gt; of this.

All well and good, but right now all this code does is create the visual effect of moving an item from one list to another.  Actually recording the fact that a particular item was moved from one list to the other requires more code, code that is invoked whenever such a move takes place.  Being the smart guys and gals that they are, the jQuery UI team built a couple of custom events into the Sortables interaction so you can run additional functions when a certain event has taken place.  For my purposes, I only needed to utilize two of these events:  &lt;strong&gt;&lt;em&gt;receive&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;remove&lt;/em&gt;&lt;/strong&gt;:

&lt;p style=&quot;background-color:#ffffcc;padding:10px;&quot;&gt;
$(document).ready({&lt;br /&gt;
&amp;nbsp;&amp;nbsp;$(&quot;#listB&quot;).sortable({&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;connectWith: [&apos;#listA&apos;],&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;receive: function(event, ui)&lt;/strong&gt; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Run this code whenever an item is dragged and dropped into this list&lt;br /&gt;  
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var itemText= ui.item.text();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;alert(itemText + &quot; just joined this list&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;},&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;remove: function(event, ui)&lt;/strong&gt;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Run this code whenever an item is dragged and dropped out of this list&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var itemText= ui.item.text();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;alert(itemText + &quot; just left this list&quot;);&lt;br /&gt;		
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;});&lt;br /&gt;
});
&lt;/p&gt;

...The code is, for the most part, self-explanatory, save for one line (repeated twice):

&lt;strong&gt;&lt;em&gt;var itemText= ui.item.text()&lt;/em&gt;&lt;/strong&gt;

The &lt;strong&gt;ui&lt;/strong&gt; object is a &quot;prepared&quot; object created by jQuery UI that holds a number of objects and data associated with the event that just took place. The &lt;strong&gt;item&lt;/strong&gt; object within the &lt;strong&gt;ui&lt;/strong&gt; object represents the item that was moved in or out of the list, so I can treat it as a jQuery object and retrieve the text of the item using the standard text() function.  You can find a full list of the data contained in the &lt;strong&gt;ui&lt;/strong&gt; object by clicking on the &quot;Overview&quot; tab at the bottom of the main &lt;a href=&quot;http://jqueryui.com/demos/sortable/&quot; target=&quot;_blank&quot;&gt;Sortables interaction web page&lt;/a&gt;.

I created my own demo page to illustrate how this code works (with a homage to the Fox TV show &quot;Fringe&quot;):

&lt;a href=&quot;http://www.swartzfager.org/blog/demoFiles/connectedSortables/connectedSortableEvents.cfm&quot; target=&quot;_blank&quot;&gt;http://www.swartzfager.org/blog/demoFiles/connectedSortables/connectedSortableEvents.cfm&lt;/a&gt;
&lt;br /&gt;&lt;br /&gt;

Two things worth mentioning at this point:

&lt;ul&gt;
&lt;li&gt;If one of your lists starts off empty, or if there&apos;s any chance that a user might remove all of the items from a list and then try to put items back into the now-empty list, you need to set a minimum height for that &amp;lt;ul&amp;gt;, so that even when empty, the &amp;lt;ul&amp;gt; is large enough to accomodate a single list element.  In Firefox and Safari, you can set the minimum height using the &lt;em&gt;min-height&lt;/em&gt; CSS style, but if you have to support IE 7, you&apos;ll have to add two additional &lt;em&gt;height&lt;/em&gt; styles (like so):
 &lt;ul style=&quot;list-style-type:none;&quot;&gt;
  &lt;li&gt;
    &lt;em&gt;
    min-height:50px;&lt;br /&gt;
    height:auto !important;&lt;br /&gt;
    height:50px;&lt;br /&gt;
    &lt;/em&gt;
  &lt;/li&gt;
 &lt;/ul&gt;
&lt;/li&gt;

&lt;li&gt;
  In my demo, you&apos;ll notice that as you drag a person out of the Candidates list, the list item&apos;s width gets shrunk to the width of the longest unbroken string of text in the list item.  I&apos;m not sure why it does that, but you can negate that effect by either defining a set width for the &amp;lt;li&amp;gt; elements, or by defining a &quot;helper&quot; with a set width (a helper is a visual representation of the item being moved, using something graphical like an icon).
&lt;/li&gt;
&lt;/ul&gt;

So, armed with this knowledge about the Sortables interaction, I was able to build the tool required by my clients.  Every time a volunteer was moved into or out of a committee, the receive or remove event would make an AJAX call to update the volunteer&apos;s record (either providing the id of the committee they were placed in or removing it), and it would run a function that updated the vacancy count for that committee specific to that type of person and counted the overall number of vacancies for that committee (to determine if the committee had been &quot;filled&quot;).  I also added a few toggles allowing them to hide extraneous information when they only wanted to see the data pertinent to doing placements for a particular committee.  The final challenge was to scale everything so that the tool could be viewed with a projector, so that the members of the group responsible for making the placements could work on it collaboratively.

I wasn&apos;t comfortable sharing an exact copy of the tool I created, but I have posted a facsimile that&apos;s fairly close to it, minus any real-life data and any AJAX calls to save the placements between page reloads.  You can view it here (Note: it doesn&apos;t work in IE 7):

&lt;a href=&quot;http://www.swartzfager.org/blog/demoFiles/connectedSortables/volunteerPlacement.cfm&quot; target=&quot;_blank&quot;&gt;http://www.swartzfager.org/blog/demoFiles/connectedSortables/volunteerPlacement.cfm&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;

...I provided instructions at the top, but quite honestly I think most IT-inclined folks could figure it out without them.

It&apos;s just one example of some of the really cool (yet practical) user interfaces made possible with jQuery and jQuery UI. 
				</description>
				
				<category>Web development</category>
				
				<category>jQuery</category>
				
				<category>JavaScript</category>
				
				<pubDate>Fri, 20 Mar 2009 12:01:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2009/3/20/Using-jQuery-UI-Sortables-To-Move-Items-From-One-List-To-Another</guid>
				
			</item>
			
			<item>
				<title>Introducing the tableFormSynch jQuery Plugin</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2009/1/7/Introducing-the-tableFormSynch-jQuery-Plugin</link>
				<description>
				
				These days, there are a number of options for creating tables where a user can click on a cell and edit the data in that cell using JavaScript (CFML&apos;s &lt;a href=&quot;http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_g-h_03.html&quot; target=&quot;_blank&quot;&gt;&amp;lt;cfgfid&amp;gt;&lt;/a&gt;, the &lt;a href=&quot;http://www.appelsiini.net/projects/jeditable&quot; target=&quot;_blank&quot;&gt;Jeditable&lt;/a&gt; jQuery plugin, etc.).  Those work fine for simple tables, but they&apos;re not great solutions when you want to:

&lt;ul&gt;
&lt;li&gt;Work with record data you&apos;re unwilling or unable to display in the table, lest the table become too long horizontally.&lt;/li&gt;
&lt;li&gt;Update data related to the row record that could have multiple values (example: the list of skills an employee has).&lt;/li&gt;
&lt;/ul&gt;

My new plugin, &lt;a href=&quot;http://www.swartzfager.org/blog/jQuery/plugins/tableFormSynch/&quot; target=&quot;_blank&quot;&gt;tableFormSynch&lt;/a&gt;, is designed to provide a workable alternative for those situations.  It works in conjunction with the jQuery metadata plugin (&lt;a href=&quot;http://plugins.jquery.com/project/metadata&quot; target=&quot;_blank&quot;&gt;http://plugins.jquery.com/project/metadata&lt;/a&gt;) to bind a table to a form such that you can populate the form with the data stored in a particular row and then use the form to update the data and write it back to the row.  It also has functions for creating a new row based on the data in the form, deleting a selected row, and clearing the form of all values.  It works with all form elements, including checkboxes, radio buttons, and &amp;lt;select&amp;gt;.

Because the data for each table row is stored in metadata, you don&apos;t have to display all of the data in the cells of the row:  show only the most important information in the 
row and show the rest of the information in the form.  Values from multiple related records can be stored in the metadata as arrays and viewed/updated via the form using either checkboxes or multi-select &amp;lt;select&amp;gt; boxes.

The only thing you have to watch out for is to make sure that you replace any single-quotes and double-quotes in your data before inserting that data in the metadata string (the plugin documentation covers that in more detail).

The plugin doesn&apos;t perform any AJAX operations, so you&apos;re free to use your preferred AJAX functions to write and retrieve data from the server.  The plugin also isn&apos;t particular about how you populate the data in your rows, so you could generate the rows using any server-side technology:  CFML using &amp;lt;cfoutput&amp;gt;, &amp;lt;cfloop&amp;gt;, or an &lt;a href=&quot;http://ibo.riaforge.org/&quot; target=&quot;_blank&quot;&gt;IBO&lt;/a&gt;, PHP, ASP, etc.  You&apos;re also free to use your favorite functions for validating the form data.

To view a demo and download the plugin, visit: 

&lt;a href=&quot;http://www.swartzfager.org/blog/jQuery/plugins/tableFormSynch/&quot;&gt;http://www.swartzfager.org/blog/jQuery/plugins/tableFormSynch/&lt;/a&gt; 
				</description>
				
				<category>jQuery</category>
				
				<category>JavaScript</category>
				
				<pubDate>Wed, 07 Jan 2009 09:38:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2009/1/7/Introducing-the-tableFormSynch-jQuery-Plugin</guid>
				
			</item>
			
			<item>
				<title>jQuery Plugin Fling Lets You Set Up Flex-like Event Listeners</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2008/12/7/jQuery-Plugin-Fling-Lets-You-Set-Up-Flexlike-Event-Listeners</link>
				<description>
				
				I was checking Twitter on my iPod Touch when I cam across a tweet from &lt;a href=&quot;http://www.twitter.com/jquery&quot; target=&quot;_blank&quot;&gt;the jQuery Twitter account&lt;/a&gt; about a plugin called &lt;a href=&quot;http://www.command-tab.com/2008/12/04/jquery-fling/&quot; target=&quot;_blank&quot;&gt;Fling&lt;/a&gt;.

The purpose of Fling is to make it easier to manage multiple triggers and cascading events.  Fling lets you create a named event, then subscribe multiple functions to that event.  When the named event is published, those subscribed events then fire in sequence.

It reminded me of how Flex allows you to set up multiple event listeners and use event bubbling to trigger multiple events based off of a single action. 
				</description>
				
				<category>jQuery</category>
				
				<category>JavaScript</category>
				
				<pubDate>Sun, 07 Dec 2008 13:11:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2008/12/7/jQuery-Plugin-Fling-Lets-You-Set-Up-Flexlike-Event-Listeners</guid>
				
			</item>
			
			<item>
				<title>Leveraging the Ubiquity FireFox Plugin To Access CFQuickDocs Pages</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2008/8/29/Leveraging-the-Ubiquity-FireFox-Plugin-To-Access-CFQuickDocs-Pages</link>
				<description>
				
				If you&apos;re a FireFox user and you haven&apos;t tried out the new &lt;a href=&quot;http://labs.mozilla.com/2008/08/introducing-ubiquity/&quot; target=&quot;_blank&quot;&gt;Ubiquity&lt;/a&gt; plugin created by the folks at Mozilla Labs, you should.

What is Ubiquity? The short answer is it&apos;s a command-line interface for retrieving and re-purposing web content. For example, the &quot;wikipedia&quot; command built into the plugin takes the word you type in, retrieves data from the top 5 matches for that word (as you type it, no less) in Wikipedia using an API, and displays that data with clickable links to the Wikipedia pages in the command window:

&lt;img src=&quot;http://www.swartzfager.org/blog/images/ubiquity_wiki.gif&quot; /&gt;

You can see even more interesting uses for Ubiquity by watching the &lt;a href=&quot;http://labs.mozilla.com/2008/08/introducing-ubiquity/&quot; target=&quot;_blank&quot;&gt;video clip&lt;/a&gt; in the Ubiquity blog post.

One of the things about Ubiquity that hasn&apos;t been talked about very much is that you can create your own Ubiquity commands using JavaScript and then share those commands with other Ubiquity users (note to jQuery users: Ubiquity commands can use jQuery functions as well as regular JavaScript functions).  To that end, I created a very simple command that lets me call up a particular &lt;a href=&quot;http://www.cfquickdocs.com/&quot; target=&quot;_blank&quot;&gt;CFQuickDocs&lt;/a&gt; page by typing &quot;cfquickdocs&quot; and the name of the CFML tag or function I want to look up:

&lt;img src=&quot;http://www.swartzfager.org/blog/images/ubiquity_cfq.gif&quot; /&gt;

As Ubiquity commands go, it&apos;s not that impressive, but it does let me pull up a particular entry faster than I used to (which involved going into my bookmarks, clicking on the bookmark, waiting for the page to load, and then entering the tag or function I want to read about).  And all it took was one function call with four parameters:

&lt;code&gt;
makeSearchCommand({
  name: &quot;cfquickdocs&quot;,
  url: &quot;http://www.cfquickdocs.com/?getDoc={QUERY}#{QUERY}&quot;,
  icon: &quot;http://www.cfquickdocs.com/favicon.ico&quot;,
  description: &quot;Searches the CFQuickDocs for the CFML tag or function you enter.&quot;
});
&lt;/code&gt;

Sharing a Ubiquity command is simply a matter of putting the command in a JavaScript file and then creating an HTML page that calls that file.  If you already have Ubiquity installed, you can install this CFQuickDocs command into your Ubiquity plugin by going to the following URL:

&lt;a href=&quot;http://www.swartzfager.org/ubiquity/cfquickdocs.html&quot; target=&quot;_blank&quot;&gt;http://www.swartzfager.org/ubiquity/cfquickdocs.html&lt;/a&gt;

If you don&apos;t have Ubiquity installed but want to learn more about developing Ubiquity commands, there is an 
&lt;a href=&quot;https://wiki.mozilla.org/Labs/Ubiquity/Ubiquity_0.1_Author_Tutorial&quot; target=&quot;_blank&quot;&gt;online tutorial&lt;/a&gt; that explains the basics.  Once you have the plugin installed, you&apos;ll have access to a command editor that lets you try out your commands as you code them, and you can read the code for all of the functions that come built into the plugin. 
				</description>
				
				<category>Technology</category>
				
				<category>RIAs</category>
				
				<category>Miscellaneous</category>
				
				<category>jQuery</category>
				
				<category>JavaScript</category>
				
				<pubDate>Fri, 29 Aug 2008 11:51:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2008/8/29/Leveraging-the-Ubiquity-FireFox-Plugin-To-Access-CFQuickDocs-Pages</guid>
				
			</item>
			
			<item>
				<title>My first jQuery plugin:  textCounting</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2008/7/30/My-first-jQuery-plugin--textCounting</link>
				<description>
				
				I&apos;ve blogged about things I&apos;ve done with jQuery before, but this is the first jQuery plugin I&apos;ve developed.

My textCounting plugin lets you show users how much text they&apos;ve entered into a &amp;lt;textarea&amp;gt; box and/or how much text they can still enter before reaching a set limit. The plugin can be configured to count either the number of words or number of characters entered or still available.

The plugin is designed in a way that a single call of the plugin can affect all of the &amp;lt;textarea&amp;gt;s on the same page if you follow certain element ID naming conventions.  There are a number of different configuration options, and it can be used with another jQuery plugin, the &lt;a href=&quot;http://plugins.jquery.com/project/metadata&quot; target=&quot;_blank&quot;&gt;Metadata&lt;/a&gt; plugin, to retrieve settings and data from a metadata block within the class attribute of the &amp;lt;textarea&amp;gt;s.

To see a demonstration of the plugin in action and to download the plugin, visit:

&lt;a href=&quot;http://www.swartzfager.org/blog/jQuery/plugins/textCounting/&quot;&gt;http://www.swartzfager.org/blog/jQuery/plugins/textCounting&lt;/a&gt;

I want to point out that one thing that the plugin does NOT do is enforce the word/character limit set for each &amp;lt;textarea&amp;gt;: you can apply a CSS class to the HTML element containing the count as a visual notice to the user that they&apos;ve exceeded the limit, but it doesn&apos;t actually prevent them from continuing to type.  I was originally going to provide that option, but I realized that a lot of users tend to paste content from another source in &amp;lt;textarea&amp;gt;s, especially when the content is expected to be verbose, and making the user count the words or characters in their text prior to copying it into the &amp;lt;textarea&amp;gt; defeats the purpose of providing the counter in the first place.

If any of you are interesting in writing your own jQuery plugins, I highly recommend you read Mike Alsup&apos;s blog post &lt;a href=&quot;http://www.learningjquery.com/2007/10/a-plugin-development-pattern&quot; target=&quot;_blank&quot;&gt;&quot;A Plugin Development Pattern&quot;&lt;/a&gt; on the &lt;a href=&quot;http://www.learningjquery.com&quot; target=&quot;_blank&quot;&gt;Learning jQuery&lt;/a&gt; site.  It was an invaluable resource and taught me a lot. 
				</description>
				
				<category>jQuery</category>
				
				<category>JavaScript</category>
				
				<pubDate>Wed, 30 Jul 2008 07:43:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2008/7/30/My-first-jQuery-plugin--textCounting</guid>
				
			</item>
			
			<item>
				<title>A list of jQuery plugins I use</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2008/6/28/A-list-of-jQuery-plugins-I-use</link>
				<description>
				
				As part of his &lt;a href=&quot;http://www.coldfusionjedi.com/index.cfm/2008/6/28/Ask-a-Jedi-jQuery-versus-Spry&quot; target=&quot;_blank&quot;&gt;blog post&lt;/a&gt; today, Ray Camden and a number of the folks who posted comments pointed out that while it was great that there are a lot of plugins available for &lt;a href=&quot;http://plugins.jquery.com/project/Plugins/&quot; target=&quot;_blank&quot;&gt;jQuery&lt;/a&gt;, the downside is that it&apos;s hard to know which plugins are any good.

I&apos;m not a heavy plugin user, but I&apos;d thought I&apos;d list the few plugins and jQuery UI libraries that I&apos;ve found to be very useful:

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
&lt;a href=&quot;http://www.malsup.com/jquery/form/&quot; target=&quot;_blank&quot;&gt;jQuery Form Plugin&lt;/a&gt;: this plugin appears in every project I&apos;ve done since I started using jQuery.  It makes it dead simple to submit forms via AJAX.
&lt;/p&gt;
&lt;p&gt;(Oooh, it looks like the author&apos;s added some new features since the last time I download it...I&apos;ll have to check that out).
&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;
&lt;a href=&quot;http://tablesorter.com/docs/&quot; target=&quot;_blank&quot;&gt;Tablesorter&lt;/a&gt;: this plugin was actually incorporated into version 1.0 of the &lt;a href=&quot;http://ui.jquery.com&quot; target=&quot;_blank&quot;&gt;jQuery UI library&lt;/a&gt;, but I don&apos;t see it listed in the current version of the UI library.  This plugin lets you sort a table in ascending or descending order based on a selected column.
&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;
&lt;a href=&quot;http://docs.jquery.com/UI/Sortables&quot; target=&quot;_blank&quot;&gt;Sortables UI library&lt;/a&gt;:  this part of the &lt;a href=&quot;http://ui.jquery.com&quot; target=&quot;_blank&quot;&gt;jQuery UI library&lt;/a&gt; lets you rearrange items on the page using drag-and-drop (something I&apos;ve mentioned a number of times here on my blog).
&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;
&lt;a href=&quot;http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/&quot; target=&quot;_blank&quot;&gt;TableDnD (Table Drag-and-Drop)&lt;/a&gt;: the Sortables UI library I just mentioned does not work on table rows (tables are just &quot;different,&quot; apparently), but this plugin lets you grab a row and move it up or down within the table. 
&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;
&lt;a href=&quot;http://www.curvycorners.net/&quot; target=&quot;_blank&quot;&gt;curvyCorners&lt;/a&gt;: after trying a few different plugins aimed at letting you create curved corners for certain HTML elements (like &amp;lt;div&amp;gt;s), this plugin, although not perfect, seemed to work best.
&lt;/p&gt;
&lt;p&gt;
I must say that I couldn&apos;t get it to work right in IE, but that might have been because of the way I was using it.  And it looks like the author has released a few updates since I last downloaded it, so that may not be an issue anymore.
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Anyone else have any jQuery plugins they&apos;d recommended using?  Or recommend avoiding?  :) 
				</description>
				
				<category>jQuery</category>
				
				<pubDate>Sat, 28 Jun 2008 17:57:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2008/6/28/A-list-of-jQuery-plugins-I-use</guid>
				
			</item>
			
			<item>
				<title>Creating a hyperlink that works with or without AJAX</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2008/5/23/Creating-a-hyperlink-that-works-with-or-without-AJAX</link>
				<description>
				
				The current project I&apos;m working on includes a display page where users can see a list of messages generated for them by the system.  Each message consists of an &amp;lt;li&amp;gt; element containing the text of the message followed by a hyperlink labeled &quot;Delete&quot;.

I wanted to make it such that you could delete each message without refreshing the page, but still accommodate users who had JavaScript turned off, and without a lot of extra work.

How did I do it?  Like so:

&lt;code&gt;
&lt;!---Include the jQuery core file---&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;/views/JavaScript/jquery-1.2.2.js&quot;&gt;&lt;/script&gt;

&lt;script language=&quot;javascript&quot;&gt;
//Set the typical jQuery ready event handler to fire when the document is ready for manipulation

$(document).ready(function () {

//Assign a click event handler for all of the &apos;delete&apos; hyperlinks (which all have a CSS class of &apos;deleteLink&apos;)

$(&quot;.deleteLink&quot;).click(function () {

  var linkObj= $(this);
  //Take the existing URL in the &apos;href&apos; value and append an additional URL variable

  var ajaxURL= linkObj.attr(&quot;href&quot;) + &quot;&amp;js=1&quot;;

  //Remove the li list element (the parent) the link belongs to

  linkObj.parent().remove();
  
  //Make the Ajax call

  $.ajax({
   type: &quot;POST&quot;,
   url: ajaxURL
  }); //end of .ajax function


  //This statement will prevent the browser from actually navigating to the address in the link

  return false;

}); //end of .deleteLink click function

});  //end of document.ready function

&lt;/script&gt;


&lt;h2&gt;Your Messages&lt;/h2&gt;

&lt;ul&gt;
  
  &lt;cfoutput query=&quot;qryMessages&quot;&gt;
  
    &lt;li id=&quot;#messageId#&quot;&gt;
      
      #message#&lt;br /&gt;
      &lt;a class=&quot;deleteLink&quot; href=&quot;index.cfm?fuseaction=#xfa.deleteMsg#&amp;msgId=#messageId#&quot;&gt;Delete&lt;/a&gt;
    
    &lt;/li&gt;
  
  &lt;/cfoutput&gt;

&lt;/ul&gt;


&lt;/code&gt;

...The only other thing you need to do is put a conditional statement in the page/event that is called by the hyperlink that looks for the presence of the additional URL variable (&quot;js&quot; in this case).  

If JavaScript is turned off, that additional variable will not be defined and the page/event will redirect the action back to the calling page once it&apos;s done deleting the message data from the database.  

If JavaScript is turned on, the page/event will simply delete the message data (no action redirect), and the user simply sees that message item disappear from the list. 
				</description>
				
				<category>jQuery</category>
				
				<category>JavaScript</category>
				
				<category>ColdFusion</category>
				
				<pubDate>Fri, 23 May 2008 09:00:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2008/5/23/Creating-a-hyperlink-that-works-with-or-without-AJAX</guid>
				
			</item>
			
			<item>
				<title>Some updates on reordering items with jQuery</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2008/5/8/Some-updates-on-reordering-items-in-jQuery</link>
				<description>
				
				If you follow my blog at all, you know I have a keen interest in being able to reorder items in a list and then record that change in order in a database using JavaScript, specifically with the jQuery UI Sortables component.  Here&apos;s some things I&apos;ve learned recently regarding the topic:

&lt;strong&gt;Reordering Nested Lists&lt;/strong&gt;

In my last project, I created a tool that allowed my clients to rearrange nested lists of articles and article categories using the jQuery UI Sortables component and the techniques I demonstrated in an earlier blog post.

My clients were very excited about the tool when they saw it in the prototype, but they ran into some difficulty when they tried to use it themselves during the final testing.  They found it hard to place an item at either end of a list block because there were no visual cues outlining the borders of the list.  

It was also nearly impossible for them to move an item around in the top-most list:  if they tried to place it in between sibling items or at the end of the list, the item would almost always get dropped at the end of whatever sublist came at the end of the sibling item above.  

Finally, the scrollable &amp;lt;div&amp;gt; element containing the nested lists would not scroll to match the drag movement of the cursor, so if they needed to move an item from one end of the nested lists to the other, the item would have to moved in steps.

I solved all of these problems by abandoning the drag-and-drop technique and replacing it with a version of my &quot;click-to-click move&quot; technique.  So now when they need to move an item, they click on an icon associated with each item (hidden until needed), and target &amp;lt;div&amp;gt;s are created above and below each item:

&lt;img src=&quot;http://www.swartzfager.org/blog/images/itnScreenShot.gif&quot; alt=&quot;Image of move targets in my last project&quot; style=&quot;padding:3px;border:1px solid gray;&quot; /&gt;

They then just click on the target for the place they want the item moved to, and the item is &quot;moved&quot; and the targets are removed (technically, the item is cloned, the clone is put in the new position, and the original item is deleted).

They like the &quot;click-to-click move&quot; version a lot better, so perhaps that&apos;s a better means of reordering items when using nested lists.  But I recently discovered &lt;a href=&quot;http://www.gimiti.com/kltan/wordpress/?p=29&quot; target=&quot;_blank&quot;&gt;jTree&lt;/a&gt;, a brand-new jQuery plugin someone wrote specifically for sorting nested lists using drag-and-drop.  I tried out the demo for it, and it has visual cues to help you position items in the right list, but it does flicker a bit at times.  Still, I might play with it the next time I have to deal with nested lists again.

&lt;strong&gt;Reordering Table Rows&lt;/strong&gt;

Lists are nice, but they don&apos;t cut it when each item is really a collection of separate items:  that&apos;s when you need a table.  In my current project, I needed a way to reorder the rows in my table as a means of letting the user reorder the data records.  The jQuery UI Sortables component, however, does not work on table rows.  

I tried to create a pseudo-table by using &amp;lt;div&amp;gt;s within each &amp;lt;li&amp;gt; item to evenly space the data fields in each row.  I got it working and looking slightly less than ugly in FireFox, but it didn&apos;t fare so well in IE.

I then went browsing through the &lt;a href=&quot;http://groups.google.com/group/jquery-ui?lnk=gschg&quot; target=&quot;_blank&quot;&gt;jQuery UI discussion board on Google Groups &lt;/a&gt; and found a post that mentioned a plugin for sorting/rearranging table rows.

It&apos;s called &lt;a href=&quot;http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/&quot; target=&quot;_blank&quot;&gt;TableDnD&lt;/a&gt;, and it&apos;s a slightly different approach to the challenge.  When you click on a row and drag it, there is no drag outline and no gradual movement:  if you move up far enough, the content of the row you&apos;re dragging and the row above it quickly switch places, and vice-versa if you move downward.  It highlights the moving row as you move it so you can keep track of what&apos;s happening.  The movement is very smooth and you can go as fast as you like.

The only drawbacks I&apos;m aware of so far is that the dragging action will not trigger the scroll bar if you&apos;re trying to drag the row beyond the visual limit of the window or scrollable container (much like my original nested list tool), and someone pointed out to me that if you fill all of the cells in a row with other DOM elements such that you cannot click on any of the cells themselves, you won&apos;t be able to grab the row and move it.  That&apos;s not a problem your table cells just contain text, but it&apos;s something to keep in mind if you plan on formatting the text with &amp;lt;span&amp;gt; tags or providing input boxes for the user to edtit the cell data. 
				</description>
				
				<category>RIAs</category>
				
				<category>jQuery</category>
				
				<category>JavaScript</category>
				
				<pubDate>Thu, 08 May 2008 21:39:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2008/5/8/Some-updates-on-reordering-items-in-jQuery</guid>
				
			</item>
			
			<item>
				<title>Problem: No Drag-and-Drop On The iPhone/iPod Touch.  Solution:  Click-To-Click Move</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2008/3/20/Problem-No-DragandDrop-On-The-iPhoneiPod-Touch--Solution--ClickToClick-Move</link>
				<description>
				
				As I mentioned in an earlier blog post, the drag-and-drop functions provided by various JavaScript libraries (jQuery, YUI, etc.) won&apos;t work in the iPhone/iPod Touch Safari web browser because the dragging gesture is used for scrolling around the web page.

That&apos;s a big problem for those of us who use drag-and-drop in our web applications to allow our users to reorder the items in a list, but I&apos;ve come up with an alternative method for rearranging items using the &lt;a href=&quot;http://www.jquery.com&quot; target=&quot;_blank&quot;&gt;jQuery JavaScript library&lt;/a&gt; that works on the iPhone/iPod browser as well as regular browsers.  I call it the &quot;Click-to-Click Move&quot; method (CTCM).  [More]
				</description>
				
				<category>Web development</category>
				
				<category>RIAs</category>
				
				<category>jQuery</category>
				
				<pubDate>Thu, 20 Mar 2008 07:19:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2008/3/20/Problem-No-DragandDrop-On-The-iPhoneiPod-Touch--Solution--ClickToClick-Move</guid>
				
			</item>
			
			<item>
				<title>ColdFusion 8&apos;s Image Functions + jQuery= A UI For Adding Text and Color Blocks Into An Image file</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2008/2/27/ColdFusion-8s-image-functions--jQuery-image-captioning-application</link>
				<description>
				
				One of the new features in &lt;a href=&quot;http://www.adobe.com/products/coldfusion&quot; target=&quot;_blank&quot;&gt;ColdFusion 8&lt;/a&gt; is the ability to manipulate images using ColdFusion tags and functions.  For example, the code below (all server-side code) will take an image file on the server, overlay it with text, and create a brand new image file in temp space and display it to the browser:

&lt;code&gt;
&lt;!---Assign the image file to the carImage variable---&gt;
&lt;cfimage name = &quot;carImage&quot; action=&quot;read&quot; source=&quot;ferrari.gif&quot;/&gt;
&lt;!---Add the text &quot;Fast car!&quot; to the image and place it 10 pixels from the left and 15 from the top---&gt;
&lt;cfset ImageDrawText(carImage, &quot;Fast car!, 10, 15)&gt;
&lt;!---Display the new image---&gt;
&lt;cfimage source=&quot;#carImage#&quot; action=&quot;writeToBrowser&quot;&gt;
&lt;/code&gt;

A week ago, an idea popped into my head:  &quot;What if you could create a UI tool that would let a user decide what text should appear on the image and where it should appear?&quot;

I decided to try and answer that question.  The result: a working proof-of-concept that lets you add text and blocks of color anywhere on a selected image using a UI tool powered by &lt;a href=&quot;http://www.jquery.com&quot; target=&quot;_blank&quot;&gt;jQuery&lt;/a&gt; JavaScript functions.  When you&apos;re done manipulating the image, you submit the data defining your changes to ColdFusion via an AJAX call, and ColdFusion creates a new image in temp space based on that data and displays it.  You can save the new image down to your computer or store the data you submitted in the database so the image you made can be reproduced without permanently storing a new image file.

The fact that it only took me a week to do this (no more than 25 hours) is a testament to both the power and simplicity of ColdFusion and jQuery.

You can try out the proof-of-concept at:
&lt;a href=&quot;http://www.swartzfager.org/captionator&quot;&gt;http://www.swartzfager.org/captionator&lt;/a&gt;

&lt;strong&gt;Update:&lt;/strong&gt; I updated the title as I realized that describing this as an &quot;image captioning program&quot; might be interpreted as simply storing captions to associate with an image, not adding the text onto/into the image. 
				</description>
				
				<category>jQuery</category>
				
				<category>JavaScript</category>
				
				<category>ColdFusion</category>
				
				<pubDate>Wed, 27 Feb 2008 07:30:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2008/2/27/ColdFusion-8s-image-functions--jQuery-image-captioning-application</guid>
				
			</item>
			
			<item>
				<title>Changing Individual CSS Styles with jQuery</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2008/2/21/Changing-Individual-CSS-Styles-with-jQuery</link>
				<description>
				
				Back when I was writing my own custom JavaScript functions, I learned that there wasn&apos;t a single, simple way to change the individual style settings (like &quot;font-weight:bold&quot;) for an HTML element that worked on every browser.  My solution was to change the CSS classes assigned to the element instead:  I wrote a library function that would allow me to add, remove, or replace any class assigned to an HTML element and simply created as many class definitions as I needed in order to accommodate the style changes.  It was actually a pretty effective workaround because it let me effectively change multiple styles with one function call.

When I started using jQuery, I quickly learned about the &quot;addClass&quot; and &quot;removeClass&quot; core functions, which I could use instead of my library function:

&lt;code&gt;
$(&quot;#missionStatement&quot;).addClass(&quot;importantTextClass&quot;);
$(&quot;#userProfile&quot;).removeClass(&quot;hideTextClass&quot;);
&lt;/code&gt;

...So I continued with my routine of changing styles by changing classes, even though sometimes I only needed to change or remove a single style setting.  No harm, no foul.

But changing classes wouldn&apos;t work for the wacky little project I&apos;ve been working on recently:  I needed to be able to change several styles for an HTML element individually, and writing a class to handle every permutation of the possible style combinations was impractical.

So I went to the &lt;a href=&quot;http://www.jquery.com&quot; target=&quot;_blank&quot;&gt;jQuery web site&lt;/a&gt;, hopeful that the brilliant folks at jQuery had something that could help me out.

And they did:  the &quot;css&quot; core function allows you to read or set any individual style or styles:

&lt;code&gt;
if ($(&quot;#missionStatement&quot;).css(&quot;font-weight&quot;)== &quot;400&quot; || $(&quot;#missionStatement&quot;).css(&quot;font-weight&quot;)== &quot;normal&quot;)
 {
   $(&quot;#userProfile&quot;).css(&quot;display&quot;,&quot;none&quot;);    
   $(&quot;#missionStatement&quot;).css({ fontSize:&quot;24px&quot;, fontWeight:&quot;bold&quot; });
  }
&lt;/code&gt;

Have I mentioned that I love jQuery?  :) 
				</description>
				
				<category>jQuery</category>
				
				<category>JavaScript</category>
				
				<category>CSS</category>
				
				<pubDate>Thu, 21 Feb 2008 07:20:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2008/2/21/Changing-Individual-CSS-Styles-with-jQuery</guid>
				
			</item>
			
			<item>
				<title>Alpha Releases Out of Updated jQuery UI and Brand-New jQuery Enchant Libraries</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2008/2/7/Alpha-Releases-Out-of-Updated-jQuery-UI-and-BrandNew-jQuery-Enchant-Libraries</link>
				<description>
				
				As demonstrated from some of my previous posts, I&apos;m a big fan of jQuery, so this news caught my attention.  

The new jQuery Enchant library is a library of visual effects:  bouncing, shaking, fading, folding, exploding (didn&apos;t know what to expect with that one), etc.

Here&apos;s the link to the announcement on Google Groups:

&lt;a href=&quot;http://groups.google.com/group/jquery-ui/browse_thread/thread/db8276574e20a5be/6a406868c7390d83#6a406868c7390d83&quot;  target=&quot;_blank&quot;&gt; Get it while it&apos;s hot: jQuery UI 1.5a and jQuery Enchant 1.0a!&lt;/a&gt;

In the thread, you&apos;ll find the links to the alpha demo pages.

Apparently, there will also be an update to the jQuery core file in order to support these alpha releases (also mentioned in the thread linked above). 
				</description>
				
				<category>JavaScript</category>
				
				<category>jQuery</category>
				
				<pubDate>Thu, 07 Feb 2008 07:39:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2008/2/7/Alpha-Releases-Out-of-Updated-jQuery-UI-and-BrandNew-jQuery-Enchant-Libraries</guid>
				
			</item>
			
			<item>
				<title>Sorting a Nested List Using jQuery And Saving the Changes</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2008/1/27/Sorting-a-Nested-List-Using-jQuery-And-Saving-the-Changes</link>
				<description>
				
				&lt;img src=&quot;http://www.swartzfager.org/blog/images/nestedListSort.gif&quot; alt=&quot;A screenshot of the sorting demo&quot; style=&quot;float:left;border:1px solid black;margin:1.2ex;&quot; /&gt;A reader asked me if it was possible to sort/rearrange items in nested lists (lists within a main list) using the &lt;a href=&quot;http://ui.jquery.com/&quot; target=&quot;_blank&quot;&gt;jQuery UI&lt;/a&gt; Sortables code.  I told him that it was, and I had actually created a tool for a client recently that made use of that feature.  

He wanted to know more about how to do it, so I went ahead and created a downloadable working demo of how to do it.  [More]
				</description>
				
				<category>Web development</category>
				
				<category>jQuery</category>
				
				<category>JavaScript</category>
				
				<category>Downloads</category>
				
				<pubDate>Sun, 27 Jan 2008 16:56:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2008/1/27/Sorting-a-Nested-List-Using-jQuery-And-Saving-the-Changes</guid>
				
				<enclosure url="http://www.swartzfager.org/blog/enclosures/nestedListSortDemo.zip" length="141076" type="application/zip"/>
				
			</item>
			
			<item>
				<title>Techniques For Providing Instructions Within A Web Application</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2008/1/22/Techniques-For-Providing-Instructions-Within-A-Web-Application</link>
				<description>
				
				Some of the processes you find in web applications are fairly standard.  Most folks can fill out a contact form, or fill out a survey, or make a calendar entry without the need for too much explanation.  But what do you do when the form involves business rules that the user may or may not know, or presents the user with a number of options?  [More]
				</description>
				
				<category>Web development</category>
				
				<category>Miscellaneous</category>
				
				<category>jQuery</category>
				
				<pubDate>Tue, 22 Jan 2008 20:40:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2008/1/22/Techniques-For-Providing-Instructions-Within-A-Web-Application</guid>
				
			</item>
			
			<item>
				<title>How to Use the Same Server-Side Code to Validate Form Data With or Without AJAX Using jQuery</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2007/12/29/Simple-technique-for-using-serverside-validation-code-for-client-OR-serverside-form-validation</link>
				<description>
				
				In any web application, if the user submits information to be stored in a database using a form, you always want to validate that information before it&apos;s stored in the database.  The majority of users have JavaScript enabled in their web browser, allowing you to use JavaScript functions to validate the data on the client-side before the submission is allowed to proceed.  However, there are those rare individuals who have JavaScript turned off, so a conscientious developer will also validate the submitted data on the server side as well as a backup.

The problem with this is that you end up having to maintain two sets of validation functions, which means twice the work if you have to make a change to the submission form or the validation rules themselves.  In addition, if you&apos;re not experienced with JavaScript, you may find it harder to write the JavaScript validation code than similar code in your server-side programming language of choice.

In an earlier blog post, I wrote about how the latest version of ColdFusion, ColdFusion 8, provides a new tag called &amp;lt;cfajaxproxy&amp;gt; that allows you to make JavaScript calls to functions contained in ColdFusion Component (CFC) files on the server, enabling you to write your validation code within CFC functions and call them for either client-side or server-side validation.  

But what if you&apos;re not running ColdFusion 8 yet, or you&apos;re using another web programming language (like PHP)?

Here&apos;s a technique I came up with using the &lt;a href=&quot;http://jquery.com/&quot;&gt;jQuery JavaScript library&lt;/a&gt; and the &lt;a href=&quot;http://malsup.com/jquery/form/&quot;&gt;jQuery Form plugin&lt;/a&gt; that lets you write your validation and database-update code on the server-side in such a way that you can either call it via AJAX if JavaScript is enabled or run it server-side if JavaScript isn&apos;t available:  [More]
				</description>
				
				<category>Miscellaneous</category>
				
				<category>jQuery</category>
				
				<category>JavaScript</category>
				
				<category>ColdFusion</category>
				
				<pubDate>Sat, 29 Dec 2007 11:45:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2007/12/29/Simple-technique-for-using-serverside-validation-code-for-client-OR-serverside-form-validation</guid>
				
				<enclosure url="http://www.swartzfager.org/blog/enclosures/submitDemo.zip" length="35920" type="application/zip"/>
				
			</item>
			
			<item>
				<title>UI Tool:  Rearranging Items in a List, jQuery-style!</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2007/11/11/UI-Tool--Rearranging-Items-in-a-List-jQuerystyle</link>
				<description>
				
				A few weeks ago, as part of an application prototype for a client, I used the fairly new jQuery UI library to create a UI tool where a user could rearrange a list of items by dragging and dropping them into different positions and then save those changes to the database.

I now have a public example posted and available for download--check it out using the link below or via the link in my Downloads list on the right:

&lt;a href=&quot;/blog/jQuerySortList.cfm&quot;&gt;List Sort Control (with jQuery)&lt;/a&gt;

It works in FireFox, IE, and Opera, and can be used in conjunction with any web application programming language. 
				</description>
				
				<category>jQuery</category>
				
				<category>JavaScript</category>
				
				<category>Downloads</category>
				
				<category>CSS</category>
				
				<pubDate>Sun, 11 Nov 2007 10:47:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2007/11/11/UI-Tool--Rearranging-Items-in-a-List-jQuerystyle</guid>
				
			</item>
			
			<item>
				<title>Advantages of the jQuery Ready event</title>
				<link>http://www.swartzfager.org/blog/index.cfm/2007/10/31/Advantages-of-the-jQuery-Ready-event</link>
				<description>
				
				I&apos;ve been working with jQuery for a few weeks now as part of a project, and I love it.  I&apos;ve always preferred to roll my own JavaScript, but from now on I plan to write all of my JavaScript utilizing the features provided by jQuery.

One of the most significant features of jQuery is it&apos;s document ready function:

&lt;code&gt;
$(document).ready(function(){
   // Your code here
 });
&lt;/code&gt;

It allows you to assign functions that will execute when an event like a mouse click occurs on the selected HTML element(s) (hyperlinks, divs, buttons, etc.).  This allows you to separate the JavaScript calls from the HTML code itself--instead of writing:

&lt;code&gt;
&lt;input type=&quot;button&quot; id=&quot;mainLink&quot; value=&quot;Show Picture&quot; onClick=&quot;showPic();&quot; /&gt;
&lt;/code&gt;

...you can assign the click event to the mainLink button in a separate JavaScript file (referenced by the HTML file)...

&lt;code&gt;
$(document).ready(function(){

   $(&quot;#mainLink&quot;).click (function () {
     showPic();
   });

 });
&lt;/code&gt;

...and leave the button free of that markup:

&lt;code&gt;
  &lt;input type=&quot;button&quot; id=&quot;mainLink&quot; value=&quot;Show Picture&quot; /&gt;
&lt;/code&gt;

The other benefit to this technique is that if you have a client that likes to alter the HTML code of the pages you wrote for them, but you&apos;re afraid they might screw up the JavaScript calls in the page, you can use jQuery to create all of the event handlers and the client won&apos;t have to worry about avoiding JavaScript code in the document. 
				</description>
				
				<category>JavaScript</category>
				
				<category>jQuery</category>
				
				<pubDate>Wed, 31 Oct 2007 07:32:00 -0400</pubDate>
				<guid>http://www.swartzfager.org/blog/index.cfm/2007/10/31/Advantages-of-the-jQuery-Ready-event</guid>
				
			</item>
			</channel></rss>