# Help with an App Architecture question

**URL:** <https://www.ruby-forum.com/t/help-with-an-app-architecture-question/173743>\
**Category:** Rails\
**Created:** [August 14, 2009, 3:18am UTC](https://www.ruby-forum.com/t/help-with-an-app-architecture-question/173743 "2009-08-14T03:18:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![RVince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@RVince](https://www.ruby-forum.com/u/RVince)\
**Post date:** [August 14, 2009, 3:18am UTC](https://www.ruby-forum.com/t/help-with-an-app-architecture-question/173743/1 "2009-08-14T03:18:23Z")

</div>

I have a view that has a swath of innerHTML in it. This innerHTML  
resides in an HTML table, and it is updated every second by a  
javascript timer which, through anX MLHttpRequest, reads a file of  
JSON data which is written to the server by another application.

The upshot is, this table is live on the web page. Within this table,  
I will have a link which the user can click, which would then open  
that row from that live table, in a formview to be user-edited.

I plan on using [Prototype API Documentation | Element.toggle (Deprecated URL)](http://www.prototypejs.org/api/element/toggle) to pop  
this open. The problem is, this would require a div for each row that  
would have the form. As you can see from my description, I am updating  
this row every second, and at times there can be two dozen or more  
rows – which is too much data to push through.

I’m wondering if anyonw can offer me any good ideas on how to solve  
this dilemma. I need to keep the data, the html, for the table as  
light as possible, When the user click the rows link, I need to open  
the form up within the rows (the typical type of editing behavior you  
see in web apps).

Does anyone see a better way to accomplish this? Thanks, RVince

---

<div class="post-metadata">

**Author:** ![RVince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@RVince](https://www.ruby-forum.com/u/RVince)\
**Post date:** [August 14, 2009, 11:35am UTC](https://www.ruby-forum.com/t/help-with-an-app-architecture-question/173743/2 "2009-08-14T11:35:17Z")

</div>

On Aug 14, 2:17 am, RVince [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:  
wondering if anyonw can offer me any good ideas on how to solve

> this dilemma. I need to keep the data, the html, for the table as  
> light as possible, When the user click the rows link, I need to open  
> the form up within the rows (the typical type of editing behavior you  
> see in web apps).
> 
> Does anyone see a better way to accomplish this? Thanks, RVince

Why not create the form on the fly ? Or have a single form hidden  
somewhere which you reveal and move to an appropriate location when  
needed ?

Fred

---

<div class="post-metadata">

**Author:** ![RVince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@RVince](https://www.ruby-forum.com/u/RVince)\
**Post date:** [August 14, 2009, 12:29pm UTC](https://www.ruby-forum.com/t/help-with-an-app-architecture-question/173743/3 "2009-08-14T12:29:08Z")

</div>

Fred,

I would love to create it on the fly, but cannot figure out how to. I  
was thinking of a partial, inside the div – but that actually renders  
when loaded. How would I do what you are thinking – I cant see a way  
to actually do that (what I see, are ways that APPEAR to do that, but  
really dont) -Rvince

---

<div class="post-metadata">

**Author:** ![RVince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@RVince](https://www.ruby-forum.com/u/RVince)\
**Post date:** [August 15, 2009, 5:09am UTC](https://www.ruby-forum.com/t/help-with-an-app-architecture-question/173743/4 "2009-08-15T05:09:27Z")

</div>

Fred,

I must not be understanding you correctly. I would still need to put  
an entire form inside a hidden div for each row, and do the whole  
thing in the hidden html – which is what I am trying to avoid doing.  
But I may not be understand you correctly?

---

<div class="post-metadata">

**Author:** ![RVince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@RVince](https://www.ruby-forum.com/u/RVince)\
**Post date:** [August 15, 2009, 1:00am UTC](https://www.ruby-forum.com/t/help-with-an-app-architecture-question/173743/5 "2009-08-15T01:00:42Z")

</div>

On Aug 14, 11:27 am, RVince [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Fred,
> 
> I would love to create it on the fly, but cannot figure out how to. I  
> was thinking of a partial, inside the div – but that actually renders  
> when loaded. How would I do what you are thinking – I cant see a way  
> to actually do that (what I see, are ways that APPEAR to do that, but  
> really dont) -Rvince

Well to pick something really simple:

$(‘container’).insert(“ … ”).

will add an (empty) form into the specified dom element.

Fred

---

<div class="post-metadata">

**Author:** ![RVince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@RVince](https://www.ruby-forum.com/u/RVince)\
**Post date:** [August 15, 2009, 10:02am UTC](https://www.ruby-forum.com/t/help-with-an-app-architecture-question/173743/6 "2009-08-15T10:02:04Z")

</div>

On Aug 15, 4:08 am, RVince [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Fred,
> 
> I must not be understanding you correctly. I would still need to put  
> an entire form inside a hidden div for each row, and do the whole  
> thing in the hidden html – which is what I am trying to avoid doing.  
> But I may not be understand you correctly?

Not necessarily. in one place only you could have a javascript  
function:

function createForm(container){  
$(container).insert(…)  
}

and then the various table rows have that function as their onclick  
(or you add that function as an event handler via the non obtrusive js  
way of your choice).

---

<div class="post-metadata">

**Author:** ![RVince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@RVince](https://www.ruby-forum.com/u/RVince)\
**Post date:** [August 15, 2009, 9:36pm UTC](https://www.ruby-forum.com/t/help-with-an-app-architecture-question/173743/7 "2009-08-15T21:36:51Z")

</div>

2009/8/14 RVince [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I plan on using [Prototype API Documentation | Element.toggle (Deprecated URL)](http://www.prototypejs.org/api/element/toggle) to pop

Not helping solve the problem at all but just to point out that a form  
cannot wrap a row or group of cells in a table, it is not valid html.  
The form must include the whole table or the form must lie entirely  
within one cell. Do not be led astray by the fact that it appears to  
work in some browsers, it will not work in all. It is a pain but that  
is the way it is.

Colin

---

<div class="post-metadata">

**Author:** ![RVince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@RVince](https://www.ruby-forum.com/u/RVince)\
**Post date:** [August 16, 2009, 3:22am UTC](https://www.ruby-forum.com/t/help-with-an-app-architecture-question/173743/8 "2009-08-16T03:22:46Z")

</div>

Colin,

THank you. However, in this case, the form doesn’t contain the rows,  
but actually resides between them, in a separate div if that is at all  
possible. After examining this, I am convinced there is no way to  
feasibly do it aside from say, a link in the table that opens up a  
form in redbox/lightbox. And even that may not work.

---

<div class="post-metadata">

**Author:** ![RVince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@RVince](https://www.ruby-forum.com/u/RVince)\
**Post date:** [August 16, 2009, 9:30pm UTC](https://www.ruby-forum.com/t/help-with-an-app-architecture-question/173743/9 "2009-08-16T21:30:49Z")

</div>

2009/8/16 RVince [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Colin,
> 
> THank you. However, in this case, the form doesn’t contain the rows,  
> but actually resides between them, in a separate div if that is at all  
> possible. After examining this, I am convinced there is no way to  
> feasibly do it aside from say, a link in the table that opens up a  
> form in redbox/lightbox. And even that may not work.

I may be wrong but I do not believe that a div is permitted between  
rows either. To test generate some simple a simple test html page and  
paste the source into the html validator at

> **[The W3C Markup Validation Service](https://validator.w3.org/#validate_by_input)**
>
> W3C's easy-to-use
> markup validation service, based on SGML and XML parsers.

Colin
