Chief Alchemist - Business Consulting For The 21st Century Via A Holistic & Intelligent Approach
Share ChiefAlchemist.com. RSS 2.0 feed for ChiefAlchemist.com. Sign up for the mailing list. Follow Chief Alchemist on Twitter. 'Like' the Chief Alchemist's page on Facebook. See what Chief Alchemist has been Q&A'ing on Quora. Chief Alchemist bookmarks & highlights on Diigo.com. Follow the Chief Alchemist on Digg.com. Chief Alchemist channel on Last.fm. Chief Alchemist on Flickr. Mark 'Chief Alchemist' Simchock on LinkedIn. Free Initial Consultation. Email Chief Alchemist. Phone Chief Alchemist.
  • Mark ‘Chief Alchemist’ Simchock
  • 'Email me.Email => ca .at. ChiefAlchemist .dot. com
  • 'Phone me.Alchemy United => 732 997-0028
  •  
  • Free initial consultation.Free => Initial Consultation
  • Please be sure to subscribe to your communication channels of choice.
  • Click To Close => The small green (consultation), red (email) or blue (phone) icons in the top upper right.
CURRENT “TOP 10” TOPICS TOOLS CLIENTS & PROJECTS SOURCES SEARCH HIDE
Business Consulting For The 21st Century Via A Holistic & Intelligent Approach

A dirty little secret about form updates via Ajax

FYI => I’ve been working up a jquery plugin for ExpressionEngine’s SafeCracker that would make certain updates via Ajax easier to setup.

In addition to the submit button (duh?), a cancel link also made sense (double duh?). Naturally, the cancel would reset any changes to the form. However, once values have been submitted and committed to the DB (i.e., there’s an Ajax success) the form’s defaultValues must also be updated.

Let me explain…

Let’s say the page loads and the form has 6 check boxes with the first 2 being checked. You then check 5 and 6 and submit the update via Ajax. The success comes back – so far so good. However, if you decide to edit the form again but then hit cancel, the reset will revert back to only the first 2 boxes being checked. Yes, the DB will have 1, 2, 5 & 6 checked but the post-cancel form will only show 1 and 2. Make sense?

The moral of the story…make sure to update a form elements’ defaultValue once you have a successful Ajax update, else any cancel / reset going forward could yield misleading results.

Ideally I’ll have a beta of this new plugin ready by the end of the week. If you’re interested in experimenting with the alpha let me know. Even if you’re not using EE you can “borrow” the snippet that “refreshes” the form.

Required.
Will not be published. Required.
Please include http://