A Javascript QuickForm Renderer?
| From: | Ken Restivo | Date: | Thu, 10 Nov 2005 19:48:06 +0000 |
| Subject: | A Javascript QuickForm Renderer? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-21878@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Has anyone given any thought to, or started work on, a JavaScript Renderer for QF?
I'm trying to add some JSON functionality to my application. I'd like to have any
sub-forms built on the server side, as requested by the user, and ship them to the browser via JSON.
This would need to be on-demand because some of my forms have quite a few sub-forms, which then can
nest quite deeply, and it wouldn't be OK to render them all and hide them on every page.
I prototyped this using QF's default renderer, rendering the form as HTML and shipping it to
the browser, and using getElementById('somediv').innerHTML = subFormHTMLFromJSON to inject
it into the page. And it worked!
Sort of. Except for one fatal problem: the DOM doesn't seem to know about the stuff I inject
using this innerHTML hack. And some of my my custom elements have JS which requires accessing other
elements through the DOM. Drat.
So, what I want to do instead, is have QuickForm render the form by generating JavaScript code
instead of HTML: basically a series of createElement() and appendChild() calls. Then, I would
Services_JSON::encode() it and ship it over to the browser, and instead of innerHTML'ing it,
I'd eval() the supplied JavaScript, and my elements would get added to the DOM properly. Or
that's the idea, anyway.
Has anyone done anything like this? Or know of any reason why it wouldn't work? I didn't
find anything through Google. Anyone else interested in this kind of thing (and ideally helping with
it) or would I be going it alone?
- -ken
- --
- ---------------
The world's most affordable web hosting.
http://www.nearlyfreespeech.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFDc6P2e8HF+6xeOIcRAm2TAKDnMrgOHKs95Zlo2YN1xLdWk7FlfwCfR3+M
lOghk+/Qd7K+udDVL113JtQ=
=t00A
-----END PGP SIGNATURE-----