Forum: Rails Spinoffs (closed, excessive spam) Element.insert?

Posted by AlannY (Guest)
on 2008-06-20 16:35
(Received via mailing list)
I want to implement that: move rows in table. Push one button and
specified row moves up (or down).

First of all, I have the following table:

<table id="table">
<tr id="row1">
    <td>Test 1</td>
    <td>Test 2</td>
</tr>
<tr id="row2">
    <td>Test 3</td>
    <td>Test 4</td>
</tr>
<tr id="row3">
    <td>Test 5</td>
    <td>Test 6</td>
</tr>
</table>

It's not a problem to move <row2> to the top or bottom, 'cause I can
do:

var row2 = $('row2').remove();
$('table').insert({top: row2});
<or>
$('table').insert({bottom: row2});

That is. The same with moving <row1> to the bottom or <row3> to the
top ;-)

But, I want to insert <row1> AFTER <row2>. How to do it? As I Imaging
it - first of all, I should remove <row1> from table and this is not a
problem (as you can see), and then <insert> it in given position ;-)

In any case: why Element.insert are some worth documented? There are
also no documentation for {top:} or {bottom:} params.

Thank you ;-)
Posted by Frederick Polgardy (Guest)
on 2008-06-20 16:59
(Received via mailing list)
What about $('row2').insert({after: $('row1')})?

-Fred

On Fri, Jun 20, 2008 at 9:35 AM, AlannY <m@alanny.ru> wrote:

>
> I want to implement that: move rows in table. Push one button and
> specified row moves up (or down).


--
Science answers questions; philosophy questions answers.
Posted by AlannY (Guest)
on 2008-06-20 17:33
(Received via mailing list)
Thanks ;-)
Posted by Matt Foster (Guest)
on 2008-06-20 21:36
(Received via mailing list)
Nice one Frederick, I didn't know about that one, looking at the
documentation though, its a bit sparing, a list of possible positions
would do well there.

http://www.prototypejs.org/api/element/insert


--
Matt Foster
Ajax Engineer
Nth Penguin, LLC
http://www.nthpenguin.com
Posted by Frederick Polgardy (Guest)
on 2008-06-20 21:57
(Received via mailing list)
Yeah, I've pretty much acclimated to going to the source code when I 
need an
answer to that type of question. :-)

I believe you can pass top, bottom, before, and after as keys to the 
insert
hash, and if it's a plain value (a string, or something with toHTML() or
toElement() defined), it's assumed to be bottom.  Top and bottom insert 
as
first child and last child, respectively, while before and after create 
an
immediate sibling above or below.

-Fred

On Fri, Jun 20, 2008 at 2:36 PM, Matt Foster <mattfoster01@gmail.com> 
wrote:

>
> Nice one Frederick, I didn't know about that one, looking at the
> documentation though, its a bit sparing, a list of possible positions
> would do well there.
>
> http://www.prototypejs.org/api/element/insert


--
Science answers questions; philosophy questions answers.
This topic is locked and can not be replied to.