[Javascript] Best Practices

Mike Dougherty mdougherty at pbp.com
Fri Apr 14 10:37:02 CDT 2006


I didn't think you were suggesting to have some number of extra fieldsets hidden in html.  I 
assumed you were going to have a hidden 'template' of the fieldset, then use the clone method to 
make as many copies as needed in an on-demand fashion.  The 'from scratch' method keeps the 
initial markup cleaner.
   I would recommend the hidden HTML Template.  If you write the js to clone a template, it will 
continue to be reusable on other forms as well as the future of this form.  You may move on to 
another project and will leave the form maintenance for a junior developer (or "FrontPage" 
webmaster)  If the form is ever updated with an extra field, the template clone method will 
automatically support the new element.  If you are using 'from scratch' DOM insertion for each 
element of the current form, you will likely be called back to this project to add support for the 
new field in the js code.
   Overall, the template-clone strategy is more readable and that has been (imo) a long-term win 
which trumps many other influences on the implementation decision.

On Thu, 13 Apr 2006 14:42:58 -0500
  Triche Osborne <wdlists at triche-osborne.com> wrote:
> I'm building an adaptable form for a scheduling application in which the answer from a 3-5 
>button radio group determines whether or not the JS generates a variable number of extra sets of 
>compound date/time fields.
> 	To do this, I can either hide a single invisible template, then clone the template, change the 
>field names and show the resulting fields, or I can generate the extra sets "from scratch."
> 	Is either method preferred? *
> 
> Triche Osborne
> 
> *Note: If it is material to the answer, the hidden field poses no processing problems on the 
>server side, nor does it require extra s-s programming to ignore it. The remainder of the form 
>consists of a single text input, a textarea, the radio group and one compound date-time field, so 
>the hidden field is virtually immaterial to load time.
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> 
> 
> __________________________________________________________
> This message was scanned by ATX
> 3:39:37 PM ET - 4/13/2006




More information about the Javascript mailing list