On Oct 29, 2011, at 5:49 AM, Jedrin wrote:
>
> I have a page that has a very large form. That combined with the
> database is optimized for flexibility rather than speed with many
> joins and the server is not much of a machine and can be very slow
> means I would like to consider if I can load the form in pieces via
> AJAX. My question is does that violate any of the rules for forms and
> tables ? The table is inside the form and each form field is a table
> cell. If the form and table doesn't completely load but increases in
> size as each AJAX call builds it up, that seems like it would help the
> problem of the slow load, but I am not sure if I would break any HTML
> rules involving tables or forms doing it that way ? I seem to
> encounter these types of problems from time to time, but then I forget
> which thing it was after a while that the rule was about and I
> possibly get confused thinking the restriction is something different
> from what it really was. Maybe there is a good cheat sheet on what's
> not allowed in HTML and the common mistakes along those lines ?
>
The basic rule for forms in HTML is that a form is a block-level element; so any element which can accept a block-level child will happily be its daddy, and any block-level element can be its direct child. This means that a form can wrap around a table, or can be contained entirely within a TD, and a form may contain a table or a div or a p or a header or a fieldset or a list. (There's probably more, and the W3C DTD for the level of HTML you want to target would be the authoritative source for this, but think about what tags you could get away with putting as a direct child of the body tag, and that's probably the right tag to use.)
I would decouple the table cells from the individual form elements, and load only the form elements through Ajax, replacing whatever placeholder you put in the target TD.
So first pass, you make up all your TDs, and fill them with a spinner gif or whatnot. Then your Ajax callbacks target each TD and replace the spinner with the resulting form element(s). If TD is too granular, say you know that each row of the table will have 10 tds, then maybe your placeholder should be a tr with a single td set to colspan 10 and the spinner in that. Then update the TR in one whack. You'll want to put an ID on whatever element you decide to update.
Walter
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment