Re: WO and JS
Jürgen Lorenz Simon <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.devel |
|---|---|
| Message-ID | <[email protected]> |
On 19.12.2005, at 18:41, 時期精霊 wrote: > Hello list, > > I made a little component to replace the WOTextField for date, it > add a drop menu calendar. > > It works very well. What I ask is more cosmetic than anything but: > > my component include 3 script and 1 css. > > Firstly, having <script> and <link> tag in the middle of a page is > not standard, the w3c validator complain about it. > > And secondly, if I have 5 date pickers on my page, I include 5 > times the sames scripts and css. > > Any idea how to clean this a little? You could run a little piece of javascript in each of your add-on components which does the following: - check the dom model for a script element with an element-id you chose - if the script element is there, all is good and the functions defined in it can be used - if not, fetch the javascript (WOResourceManager) and create an on- the-fly script with an element-id you chose. - alternatively insert the script in the HEAD section of the DOM model, although at this point it wont make any difference. You will still get hassled by the W3C validator for the little script in your component, but this way the javascript will only get included once. Regards, J.L.Simon -- :tecc Simon,Jackson GbR Dipl. Met. Jürgen Simon Tel: +49 160 7255991 [email protected]