<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4291469331423659873</id><updated>2012-02-15T23:16:18.233-08:00</updated><category term='jquery'/><category term='javascript'/><category term='plugin'/><title type='text'>The Idea Mill</title><subtitle type='html'>Cold Fusion + jQuery + AjaxCFC = Nirvana!</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://daemach.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4291469331423659873/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://daemach.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Daemach</name><uri>http://www.blogger.com/profile/08317033799197280155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4291469331423659873.post-2322244179022772647</id><published>2007-03-14T21:23:00.000-07:00</published><updated>2007-03-14T22:55:19.513-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='plugin'/><category scheme='http://www.blogger.com/atom/ns#' term='jquery'/><title type='text'>autoSave - jQuery plugin</title><content type='html'>autoSave is the result of one too many user complaints about losing data due to session timeouts, power outages, meteor strikes and other issues beyond my control.  You can feed it one or all of your form fields and it will do an ajax post to your server whenever any of those values change, with a delay built in for text-type fields to minimize the number of ajax calls your application makes.&lt;br /&gt;&lt;br /&gt;Overkill?  Possibly, but this was more of an experiment than anything and since it could prove useful in rare circumstances I'm making it available.&lt;br /&gt;&lt;br /&gt;Please be kind - I have no formal programming training of any kind, so the code might be somewhat lacking in elegance.  In fact, "somewhat" might be a bit of an understatement...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Usage:&lt;/span&gt;  $("yourFormInputs").autoSave( Function, Map );&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Function:&lt;/span&gt; Any ajax function.  The function is called in the scope of the element itself so "this" refers to the element's properties: this.id, this.value, this.checked, etc.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Map:&lt;/span&gt; Key/value pairs as parameters&lt;br /&gt;&lt;ul&gt;&lt;li&gt;delay(ms) - for text fields, how long to wait before posting.  default 1000ms&lt;/li&gt;&lt;li&gt;beforeClass - class to apply to the element when the value has changed&lt;/li&gt;&lt;li&gt;afterClass - class to apply to the element after the ajax call has returned&lt;/li&gt;&lt;li&gt;onChange - function to run when the value changes.  By default applies beforeClass&lt;/li&gt;&lt;li&gt;preSave - function to run just before the ajax function is run.  Returning a boolean"false" from this function will prevent the ajax call from running and reverts the field to its previous value.  All other return values allow the ajax callto run normally. ( Of limited use, but why not... )&lt;/li&gt;&lt;ul&gt;&lt;li&gt;One possible use: { preSave : function (){ return confirm('are you sure?'); } }&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;postSave - function to run when the ajax call completes.  By default applies afterClass&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Caveats:&lt;/span&gt; Checkboxes have to be handled specially since they don't have separate values for checked and unchecked states.  See below for one possible solution.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example: &lt;/span&gt;&lt;span&gt;( I need to find a script formatter...)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;$(document).ready(function(){&lt;br /&gt;&lt;br /&gt;$(":input").autoSave(function(){&lt;br /&gt;&lt;br /&gt;  var ele = new Object();&lt;br /&gt;&lt;br /&gt;  // remember that this function runs in the scope of the element itself.&lt;br /&gt;  ele[this.name] = (this.type =="checkbox") ? this.value + "|" + this.checked : this.value;&lt;br /&gt;&lt;br /&gt;  $.post("test.cfm", ele, function (data) {$("#ResultDiv").empty().append(data);} )&lt;br /&gt;&lt;br /&gt;});&lt;br /&gt;});&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can download it here:  &lt;a href="http://www.synaptrixgroup.com/jquery.autoSave.js"&gt;jQuery.autoSave.js&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4291469331423659873-2322244179022772647?l=daemach.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://daemach.blogspot.com/feeds/2322244179022772647/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4291469331423659873&amp;postID=2322244179022772647' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4291469331423659873/posts/default/2322244179022772647'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4291469331423659873/posts/default/2322244179022772647'/><link rel='alternate' type='text/html' href='http://daemach.blogspot.com/2007/03/autosave-jquery-plugin.html' title='autoSave - jQuery plugin'/><author><name>Daemach</name><uri>http://www.blogger.com/profile/08317033799197280155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
