RE: [PEAR] QuickForm: Custom element type needing JavaScript

From: Date: Wed, 28 Apr 2004 07:57:26 +0000
Subject: RE: [PEAR] QuickForm: Custom element type needing JavaScript
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-12179@lists.php.net to get a copy of this message
> -----Original Message----- > From: Markus Wolff [mailto:wolff@21st.de] > Sent: 28 April 2004 01:00 > > 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. An alternative to HTML area (I've not tested) is http://www.fredck.com/fckeditor/ > 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? Another function which may be needed is the ability to attach some javascript to a form object global variable which can be appended to the form, which may execute something once the whole form is loaded in to the web browser - useful if your Javascript references multiple form elements. Two globals in the Form object would be great! - Mike C. ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________

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