Chief Alchemist - Business Consulting For The 21st Century Via A Holistic & Intelligent Approach
Share RSS 2.0 feed for 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 Follow the Chief Alchemist on Chief Alchemist channel on 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.
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.

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