QuickForm: Custom element type needing JavaScript

From: Date: Wed, 28 Apr 2004 00:00:19 +0000
Subject: QuickForm: Custom element type needing JavaScript
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-12176@lists.php.net to get a copy of this message
Hi guys, this topic has been asked already with the discussion about the HTMLArea element... but I can't recall having seen a good solution, or at least the solution I can recall has a glitch... but one thing after the other: For some elements, like HTMLArea or the one I'm writing for jsCalendar ATM, it is needed to include some custom Javascript that's needed for the elements to be displayed at all. Usually, it is enough to include these scripts just before the element is used for the first time, and making double includes can be prevented by setting a constant or a global variable after the first inclusion. However, what if I have both more than one of these elements on my page *and* use a template to properly layout the form? It is very well possible then that the elements' order of appearance in the finished form is different from the order in which they were defined in QuickForm, which can result in the Javascript files being included *after* the first element that needs them is being displayed - which means, this element will not function properly. The possible solutions I see: a) Just make the script inclusion happen for each and every element.
     This doesn't look nice in the resulting HTML document and also
     might bring some unwanted side-effects (Javascript bugs).
b) Add a method to the element classes that can add global
     Javascript code for the form object, that will be rendered
     in front of the whole form output (in other words: the same place
     where the validation Javascripts go).
c) I have missed something :-) Any thoughts on this? CU Markus

« previous php.pear.general (#12176) next »