[Bese-devel] reducing amount of javascript code for form validation

Attila Lendvai attila.lendvai at gmail.com
Sat Jul 22 16:48:17 UTC 2006


some fyi's...

* used dojo.byId instead of document.getElementById


there's a macro named $ in the ajax branch for this


> What I did not yet:
> * pulling common code into a separate static javascript file (I am not
> sure how to do it in a proper manner, because the javascript should be
> loaded only when there are UCW forms in the document)
>

you can stuff into a global js as much as you want and have the browser
cache the js file for you. see
per-application-parenscript.lisp<http://www.uncommon-web.com/darcsweb/darcsweb.cgi?r=ucw_ajax;a=headblob;f=/src/per-application-parenscript.lisp>especially
in the ajax branch where it's full of stuff already.

* pulling out generic code like a check if a number is between two other
> numbers (it would be laconic to write something like isNumberBetween
> (field.value, 2, 10);)


don't know what you mean here, but having an (
ucw.forms.validators.number.between field-id 10 20) does not seem to be that
bad. again, the ajax branch has many similar constructs...

* fixing bugs which were found in the process


there's a pending form field patch by Marijn that fixes several bugs but
it's being updated for the new infrastructure in the ajax branch that
simplifies it.

* In the form-specific javascript the "form" variable is global.
> Theoretically, this can lead to very bad consequences if there are more
> than one form on a page.


fixed in ajax: <ucw:script generates non-toplevel js unless asked for the
opposite and it can also be asked to compile the parenscript at
compile-time.

-- 
- attila

"- The truth is that I've been too considerate, and so became
unintentionally cruel...
- I understand.
- No, you don't understand! We don't speak the same language!"

Ingmar Bergman - Smultronstället (Wild Strawberries)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/bese-devel/attachments/20060722/64b0dc37/attachment.html>


More information about the bese-devel mailing list