Moving an element in the DOM

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Moving an element in the DOM

Ryan Simmons-2
I tried to move an element above its sibling using something like

html anchor
 onClick: (html evaluator
     callback: [:s |
          self moveElement.
          s element id: 'moveElement'; previous; insertBefore:
(SUElement new id: 'moveElement')]);
 with: 'move up'.

This results in the text "$('moveElement')" being inserted into the
correct position in the DOM.
I managed to get it to work the way I expected it to by changing the
following on SUElement

insert: anObject position: aString
       "Inserts anObject before, after, at the top of, or at the
bottom of element."

       self call: 'insert' argument: (Dictionary new
               at: aString put: ((anObject isKindOf: SUElement)
                                                          ifTrue: [anObject]

ifFalse:[self render: anObject]);
               yourself)

Is this the correct way to fix this or should I have gone about this
another way?

Ryan Simmons
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Moving an element in the DOM

Lukas Renggli
That's a limitation of the Scriptaculous Smalltalk-to-Javascript
conversion API. You might want to use #call:with: and directly provide
the right arguments, or add your own helper method either in Smalltalk
or in Javascript (when things get more complicated).

Cheers,
Lukas

On Tue, Nov 4, 2008 at 9:35 PM, Ryan Simmons
<[hidden email]> wrote:

> I tried to move an element above its sibling using something like
>
> html anchor
>  onClick: (html evaluator
>     callback: [:s |
>          self moveElement.
>          s element id: 'moveElement'; previous; insertBefore:
> (SUElement new id: 'moveElement')]);
>  with: 'move up'.
>
> This results in the text "$('moveElement')" being inserted into the
> correct position in the DOM.
> I managed to get it to work the way I expected it to by changing the
> following on SUElement
>
> insert: anObject position: aString
>       "Inserts anObject before, after, at the top of, or at the
> bottom of element."
>
>       self call: 'insert' argument: (Dictionary new
>               at: aString put: ((anObject isKindOf: SUElement)
>                                                          ifTrue: [anObject]
>
> ifFalse:[self render: anObject]);
>               yourself)
>
> Is this the correct way to fix this or should I have gone about this
> another way?
>
> Ryan Simmons
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>



--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside