Prototype: Update with multiple elements and texts

D

Daniel Loose

Hi,

I am new to prototype.js and appreciate it a lot.

One simple thing however seems to be impossible? I have a <td> element
which I want to fill with
- an input field
- text
- another input field

at one step.

i.e.
td = ... (simply the <td> element)
in1 = new Element('input', ...)
in2 = new Element('input', ...)

Now none of these works: (because in some cases, the element itself is
printed, not its content)

td.update(in1).update(td.innerHTML + 'bla').update(td.innerHTML + in2)

td.update(in1 + 'bla' + in2)

td.update(in1.innerHTML + 'bla' + in2.innerHTML)

....so what *does* it?

(or simply: how do I get the content of a new, not-yet-written,
element?)

Thx!


*************

Marty - it's perfect! You're just not thinking fourth dimensionally!
[Emmett "Doc" Brown]

If you wish to email me, please use newsreply at wuwei minus webservices dot de
 
K

Keith Hughitt

Hi Marty,

If you are using script.aculo.us, try checking out Builder.node and
Builder.build. Using Builder.node
you can do things like:

var td = Builder.node ('td', {style: '...'},
[Builder.node('input', ...), Builder.node('input',...), 'some plain
text, etc.']);

and Builder.build can even acccept entire xhtml fragments.
 
D

dhtml

One simple thing however seems to be impossible? I have a <td> element
which I want to fill with
- an input field
- text
- another input field

at one step.

What is wrong with innerHTML?
 
T

Thomas 'PointedEars' Lahn

Daniel said:
I am new to prototype.js and appreciate it a lot.

I am not and I do not. Exactly because you are new to it you are in no
position to assess its quality. Prototype.js is considered junk around here.
One simple thing however seems to be impossible? I have a <td> element
which I want to fill with
- an input field
- text
- another input field

at one step.

i.e.
td = ... (simply the <td> element)
in1 = new Element('input', ...)
in2 = new Element('input', ...)

The declaration for the Element constructor would overwrite the object built
into Gecko-based UAs. At least it would attempt to, we are talking host
objects here.
Now none of these works: (because in some cases, the element itself is
printed, not its content)

td.update(in1).update(td.innerHTML + 'bla').update(td.innerHTML + in2)

td.update(in1 + 'bla' + in2)

td.update(in1.innerHTML + 'bla' + in2.innerHTML)

...so what *does* it?

(or simply: how do I get the content of a new, not-yet-written,
element?)

A new element does not yet have content. `input' elements in particular
always have EMPTY content, or no content at all if you will.
[...]
If you wish to email me, please use newsreply at wuwei minus webservices dot de

There is the Reply-To header for this.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top