Iterating over a collection of tags

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

Iterating over a collection of tags

Andy Burnett
I think I have a basic misunderstanding of the JsProxy object.  What I want to do is the following:

tmp1 := 'p' asJQuery.
tmp1 do: [:each| each - some action -].

However, tmp1 reports DNU for 'do:'. 

How can I convert the object that asJQuery returns into something which I can use do: select: collect: etc., on?

Cheers
Andy
Reply | Threaded
Open this post in threaded view
|

Re: Iterating over a collection of tags

Herby Vojčík


Andy Burnett wrote:
> I think I have a basic misunderstanding of the JsProxy object. What I
> want to do is the following:
>
> tmp1 := 'p' asJQuery.
> tmp1 do: [:each| each - some action -].
>
> However, tmp1 reports DNU for 'do:'.

Array has do:, but jQuery object is not an Array for amber, use

tmp1 toArray do: [....]

Herby

> How can I convert the object that asJQuery returns into something which
> I can use do: select: collect: etc., on?
>
> Cheers
> Andy
Reply | Threaded
Open this post in threaded view
|

Re: Iterating over a collection of tags

Andy Burnett


On Wed, Jun 20, 2012 at 2:21 PM, Herby Vojčík <[hidden email]> wrote:


Andy Burnett wrote:
I think I have a basic misunderstanding of the JsProxy object. What I
want to do is the following:

tmp1 := 'p' asJQuery.
tmp1 do: [:each| each - some action -].

However, tmp1 reports DNU for 'do:'.

Array has do:, but jQuery object is not an Array for amber, use

tmp1 toArray do: [....]

Great, that fixes it.

In order to go from the jQuery object to an OrderedCollection, I seem to have to do the toArray, and then asOrderedCollection. There is no way to do this in one step, is there?

 


Herby


How can I convert the object that asJQuery returns into something which
I can use do: select: collect: etc., on?

Cheers
Andy

Reply | Threaded
Open this post in threaded view
|

Re: Iterating over a collection of tags

Herby Vojčík


Andy Burnett wrote:

>
>
> On Wed, Jun 20, 2012 at 2:21 PM, Herby Vojčík <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>
>
>     Andy Burnett wrote:
>
>         I think I have a basic misunderstanding of the JsProxy object.
>         What I
>         want to do is the following:
>
>         tmp1 := 'p' asJQuery.
>         tmp1 do: [:each| each - some action -].
>
>         However, tmp1 reports DNU for 'do:'.
>
>
>     Array has do:, but jQuery object is not an Array for amber, use
>
>     tmp1 toArray do: [....]
>
>
> Great, that fixes it.
>
> In order to go from the jQuery object to an OrderedCollection, I seem to
> have to do the toArray, and then asOrderedCollection. There is no way to
> do this in one step, is there?

In Amber, OrderedCollection is just an alias for Array (which is wrapped
javascript Array).
No need for asOrderedCollection at all.

>     Herby
>
>
>         How can I convert the object that asJQuery returns into
>         something which
>         I can use do: select: collect: etc., on?
>
>         Cheers
>         Andy
>
>