Anonymous Component

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

Anonymous Component

jrick
I'm using AJAX a decent amount with my Seaside application. One common thing is to replace an IDed element with a component using something like:
    s << (s jQuery: #event) replaceWith: self.
inside a "html jQuery ajax script: [ :s | ]" block.

Is there a way to do this replacement without using a component that implements the renderContentOn: message? For instance, what could I just do to replace the #event component with this HTML: '<b>Success</b>'? I'm hoping there's something I can do along the lines of:
    s << (s jQuery: #event) replaceWith: [ :html | 
        html html: '<b>'.
        html text: (self isSuccess
            ifTrue: [ 'Success' ]
            ifFalse: [ 'Failed' ]).
        html html: '</b>' ].

Thanks,

Jeff

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

Re: Anonymous Component

Mariano Martinez Peck


On Tue, Jan 19, 2016 at 3:11 PM, J.F. Rick <[hidden email]> wrote:
I'm using AJAX a decent amount with my Seaside application. One common thing is to replace an IDed element with a component using something like:
    s << (s jQuery: #event) replaceWith: self.
inside a "html jQuery ajax script: [ :s | ]" block.

Is there a way to do this replacement without using a component that implements the renderContentOn: message? For instance, what could I just do to replace the #event component with this HTML: '<b>Success</b>'? I'm hoping there's something I can do along the lines of:
    s << (s jQuery: #event) replaceWith: [ :html | 
        html html: '<b>'.
        html text: (self isSuccess
            ifTrue: [ 'Success' ]
            ifFalse: [ 'Failed' ]).
        html html: '</b>' ].


Jeff, I think that should work, exactly as you typed it.
It doesn't? 



--

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

Re: Anonymous Component

Esteban A. Maringolo
In reply to this post by jrick
2016-01-19 15:11 GMT-03:00 J.F. Rick <[hidden email]>:

> I'm using AJAX a decent amount with my Seaside application. One common thing
> is to replace an IDed element with a component using something like:
>     s << (s jQuery: #event) replaceWith: self.
> inside a "html jQuery ajax script: [ :s | ]" block.
>
> Is there a way to do this replacement without using a component that
> implements the renderContentOn: message? For instance, what could I just do
> to replace the #event component with this HTML: '<b>Success</b>'? I'm hoping
> there's something I can do along the lines of:
>     s << (s jQuery: #event) replaceWith: [ :html |
>         html html: '<b>'.
>         html text: (self isSuccess
>             ifTrue: [ 'Success' ]
>             ifFalse: [ 'Failed' ]).
>         html html: '</b>' ].

Unless you do some server-side component instantiation or instVar
assigment, then what you get to the block is just an WAHtmlCanvas (the
html var), it doesn't matter what/how you render on it.

So that should work out of the box.


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

Re: Anonymous Component

Johan Brichau-2
In reply to this post by jrick
Jeff,

As others have mentioned, this should work as you wrote it.
The argument to replaceWith: is any renderable. This can be component but also a rendering block ( [:html | …. ] )

Just one thing:

It’s better style to write:

(html tag: ‘b’) with: [ …. ] instead of html html: ‘<b>’

cheers
Johan

> On 19 Jan 2016, at 19:11, J.F. Rick <[hidden email]> wrote:
>
> I'm using AJAX a decent amount with my Seaside application. One common thing is to replace an IDed element with a component using something like:
>     s << (s jQuery: #event) replaceWith: self.
> inside a "html jQuery ajax script: [ :s | ]" block.
>
> Is there a way to do this replacement without using a component that implements the renderContentOn: message? For instance, what could I just do to replace the #event component with this HTML: '<b>Success</b>'? I'm hoping there's something I can do along the lines of:
>     s << (s jQuery: #event) replaceWith: [ :html |
>         html html: '<b>'.
>         html text: (self isSuccess
>             ifTrue: [ 'Success' ]
>             ifFalse: [ 'Failed' ]).
>         html html: '</b>' ].
>
> Thanks,
>
> Jeff
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

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

Re: Anonymous Component

jrick
Too funny that I guessed something that would actually work. Awesome,

Jeff

On Wed, Jan 20, 2016 at 5:40 PM Johan Brichau <[hidden email]> wrote:
Jeff,

As others have mentioned, this should work as you wrote it.
The argument to replaceWith: is any renderable. This can be component but also a rendering block ( [:html | …. ] )

Just one thing:

It’s better style to write:

(html tag: ‘b’) with: [ …. ] instead of html html: ‘<b>’

cheers
Johan

> On 19 Jan 2016, at 19:11, J.F. Rick <[hidden email]> wrote:
>
> I'm using AJAX a decent amount with my Seaside application. One common thing is to replace an IDed element with a component using something like:
>     s << (s jQuery: #event) replaceWith: self.
> inside a "html jQuery ajax script: [ :s | ]" block.
>
> Is there a way to do this replacement without using a component that implements the renderContentOn: message? For instance, what could I just do to replace the #event component with this HTML: '<b>Success</b>'? I'm hoping there's something I can do along the lines of:
>     s << (s jQuery: #event) replaceWith: [ :html |
>         html html: '<b>'.
>         html text: (self isSuccess
>             ifTrue: [ 'Success' ]
>             ifFalse: [ 'Failed' ]).
>         html html: '</b>' ].
>
> Thanks,
>
> Jeff
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

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

Re: Anonymous Component

jrick
Finally got around to trying this in my code. It worked. You know you're doing something right when people guess how to do something and it would actually work.

Cheers,

Jeff

On Thu, Jan 21, 2016 at 4:07 PM J.F. Rick <[hidden email]> wrote:
Too funny that I guessed something that would actually work. Awesome,

Jeff

On Wed, Jan 20, 2016 at 5:40 PM Johan Brichau <[hidden email]> wrote:
Jeff,

As others have mentioned, this should work as you wrote it.
The argument to replaceWith: is any renderable. This can be component but also a rendering block ( [:html | …. ] )

Just one thing:

It’s better style to write:

(html tag: ‘b’) with: [ …. ] instead of html html: ‘<b>’

cheers
Johan

> On 19 Jan 2016, at 19:11, J.F. Rick <[hidden email]> wrote:
>
> I'm using AJAX a decent amount with my Seaside application. One common thing is to replace an IDed element with a component using something like:
>     s << (s jQuery: #event) replaceWith: self.
> inside a "html jQuery ajax script: [ :s | ]" block.
>
> Is there a way to do this replacement without using a component that implements the renderContentOn: message? For instance, what could I just do to replace the #event component with this HTML: '<b>Success</b>'? I'm hoping there's something I can do along the lines of:
>     s << (s jQuery: #event) replaceWith: [ :html |
>         html html: '<b>'.
>         html text: (self isSuccess
>             ifTrue: [ 'Success' ]
>             ifFalse: [ 'Failed' ]).
>         html html: '</b>' ].
>
> Thanks,
>
> Jeff
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside