Imaginary Landscape open-sourced some work
I did recently on a Javascript library for handling repeating elements
in forms. I've rewritten it more than once since then, and might just
rewrite it again before it settles down.
After the last rewrite it more-or-less follows the WHAT-WG Web Forms 2.0 spec with respect to repeating forms. The
implementation practically falls out of the spec, so after I just read
it closely it was pretty clear how to implement it. Though, having
implemented it, I need to bring some questions back to the WHAT-WG
group -- especially related to moving repetition blocks around.
Conveniently, the spec works very well with FormEncode and variabledecode
in particular. But it's actually expedience that made me implement it
in the first place. Without repeating form elements, you have to have
multiple complex forms, with lots of add/edit/delete functionality.
With repeating forms you just have a single form, and the update is a
single HTTP request. Less templates, less things to explain, less
controllers, and a better user experience to boot.
I still have to figure out where this will go. I like MochiKit, but I've ended up factoring out nearly all
the MochiKit dependencies (not because I was trying, it just
happened). And it also fits a somewhat different style -- the
Javascript is largely implicit, based on declarative HTML as defined
in the spec. A big feature of the Web Forms 2.0 spec (IMHO) is that it
isn't expressed in Javascript, and you don't have to think about
Javascript while using it.
OTOH, I have no desire to set up a separate project or deal with any
of that. I'd much rather glom onto someone else's project ;)
I've seen other implementations of portions of WHAT-WG. But they all
seem complicated, or tied to one browser. (Well, I haven't tested on
IE yet, but that's incidental.) That seems unnecessary, because at
least large portions of Web Forms 2.0 is pretty simple Javascript.
Plus I have a hard time finding them.
Anyway, the files are temporarily located at
http://svn.colorstudy.com/home/ianb/repeat_form and a demo at
http://ianbicking.org/examples/repeat_form/form.html