adding parameters to updater

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

adding parameters to updater

Ron Teitelbaum

All,

 

Is there a way to update the attributes of the tag that is called in the SUUpdater?

 

I thought that insertion might be it (see below), I also saw SUEvent>>element but could not figure out how to get to SUEvent from updater?

 

            onClick: (html updater id: 'myID’;

                        insertion: 'background-color: ‘’blue’’;';

callback: [:rend | self renderContentsOn: rend]);

 

Thank you for any help!

 

Ron

 


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

Re: adding parameters to updater

Lukas Renggli
> Is there a way to update the attributes of the tag that is called in the
> SUUpdater?

No, you can only update the contents of the tag identified with the
#id: as a whole.

> I thought that insertion might be it (see below), I also saw

#insertion: goes together with instances of SUInsertion. It is used to
add a new element into the DOM tree, either before/after the element
or within at the top/bottom the element identified with #id:.

This is always the #callback: block used to render the element.

> SUEvent>>element but could not figure out how to get to SUEvent from
> updater?

This is the current JavaScript event within the Web-browser. It
provides the coordinates of the mouse-pointer, keyboard state, etc. It
is also possible to use SUEvent to cancel the event and stop it from
bubbling.

>             onClick: (html updater id: 'myID';
>
>                         insertion: 'background-color: ''blue'';';
>
> callback: [:rend | self renderContentsOn: rend]);

You can basically do what you want using the evaluator by injecting
JavaScript code into the page (untested):

    onClick: (html evaluator callback: [ :script |
       script element
          id: 'myId';
          addClassNamed: 'foo' ])

when you have a style-sheet with the class foo

    .foo { background-color: blue }

Since you can inject any kind of JavaScript using #evaluator you could
also try to do it directly with something like by not using what
Scriptaculous provides (untested as well):

    onClick: (html evaluator callback: [ :script |
       script add: (SUStream on: '$("myId").style.backgroundColor = "blue"') ])

Cheers,
Lukas

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

RE: adding parameters to updater

Ron Teitelbaum
Hi all,

Any idea why this doesn't work?  Maybe I do not understand updater.  I'm
trying to make this as simple as possible so I can see what it is doing?  It
seems like it is working but the javascript is not being evaluated once it
is returned to the browser.  Is there a way to see what ajax is returning?
Any ideas what I'm doing wrong?

>>renderContentOn: html

        html div id: 'ron';
                onClick: (html evaluator callback: [ :script |
        script element
        id: 'ron';
          addClassName: 'foo' ]);
        with: [
                html text: 'hello'
        ].

>>style

^
'#ron .foo {
                background-color: red;
    }

#ron {
        background-color: green;
}
        '

> -----Original Message-----
> From: [hidden email] [mailto:seaside-
> [hidden email]] On Behalf Of Lukas Renggli
> Sent: Monday, October 23, 2006 4:47 PM
> To: [hidden email]; The Squeak Enterprise Aubergines Server - general
> discussion.
> Subject: Re: [Seaside] adding parameters to updater
>
> > Is there a way to update the attributes of the tag that is called in the
> > SUUpdater?
>
> No, you can only update the contents of the tag identified with the
> #id: as a whole.
>
> > I thought that insertion might be it (see below), I also saw
>
> #insertion: goes together with instances of SUInsertion. It is used to
> add a new element into the DOM tree, either before/after the element
> or within at the top/bottom the element identified with #id:.
>
> This is always the #callback: block used to render the element.
>
> > SUEvent>>element but could not figure out how to get to SUEvent from
> > updater?
>
> This is the current JavaScript event within the Web-browser. It
> provides the coordinates of the mouse-pointer, keyboard state, etc. It
> is also possible to use SUEvent to cancel the event and stop it from
> bubbling.
>
> >             onClick: (html updater id: 'myID';
> >
> >                         insertion: 'background-color: ''blue'';';
> >
> > callback: [:rend | self renderContentsOn: rend]);
>
> You can basically do what you want using the evaluator by injecting
> JavaScript code into the page (untested):
>
>     onClick: (html evaluator callback: [ :script |
>        script element
>           id: 'myId';
>           addClassNamed: 'foo' ])
>
> when you have a style-sheet with the class foo
>
>     .foo { background-color: blue }
>
> Since you can inject any kind of JavaScript using #evaluator you could
> also try to do it directly with something like by not using what
> Scriptaculous provides (untested as well):
>
>     onClick: (html evaluator callback: [ :script |
>        script add: (SUStream on: '$("myId").style.backgroundColor =
> "blue"') ])
>
> Cheers,
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
> _______________________________________________
> 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: adding parameters to updater

Ramon Leon-5

> Hi all,
>
> Any idea why this doesn't work?  Maybe I do not understand
> updater.  I'm trying to make this as simple as possible so I
> can see what it is doing?  It seems like it is working but
> the javascript is not being evaluated once it is returned to
> the browser.  Is there a way to see what ajax is returning?

Bingo, you forgot to tell it to evalScripts!

html div
    id: 'ron';
    onClick: (html evaluator callback: [ :script |
        script element
          id: 'ron';
                        evalScripts: true;
            addClassName: 'foo' ]);
    with: 'hello'.

Ramon Leon
http://onsmalltalk.com

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

Re: RE: adding parameters to updater

Lukas Renggli
In reply to this post by Ron Teitelbaum
> Any idea why this doesn't work?  Maybe I do not understand updater.  I'm
> trying to make this as simple as possible so I can see what it is doing?  It
> seems like it is working but the javascript is not being evaluated once it
> is returned to the browser.  Is there a way to see what ajax is returning?
> Any ideas what I'm doing wrong?

FireBug is the tool to use for any questions related to JavaScript:
<https://addons.mozilla.org/firefox/1843/>

For you particular problem this is rather a CSS problem than one of
Scriptaculous. With the following code it works for me:

#ron { background-color: green; }
#ron.foo { background-color: red; }

Note that there is no space between #ron.foo as these signifies the
same element (this does not work in IE, to make it work there you
presumably have to remove the #ron). Then there is also the order that
matters in which the rules are specified (in your case it doesn't
matter as classes go after id's, but just in general ...)

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

Re: RE: adding parameters to updater

Lukas Renggli
In reply to this post by Ramon Leon-5
> Bingo, you forgot to tell it to evalScripts!

My SUEvaluator has no method called #evalScripts:, it doesn't make
much sense not to evaluate an evaluator anyway ;-)

Maybe this was different in an older version of Squeak.

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

Re: Re: RE: adding parameters to updater

Lukas Renggli
> Maybe this was different in an older version of Squeak.

Ehh ... Scriptaculous. Better going to sleep now.

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

RE: RE: adding parameters to updater

Ramon Leon-5
In reply to this post by Lukas Renggli
>
> > Bingo, you forgot to tell it to evalScripts!
>
> My SUEvaluator has no method called #evalScripts:, it doesn't
> make much sense not to evaluate an evaluator anyway ;-)
>
> Maybe this was different in an older version of Squeak.
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch


Oops, my bad, that's what I get for answering without checking my image.

Ramon Leon
http://onsmalltalk.com 

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

RE: adding parameters to updater

Ron Teitelbaum
In reply to this post by Ramon Leon-5
Hi Ramon,

Thank you for your response.  I've been reading your previous postings.  I
saw your email about evalScripts to someone else earlier.  evalScripts is
for updater not evaluator, I found that out when I tried it.  Thanks for
pointing it out, it will definitively come in handy!

Ron


> -----Original Message-----
> From: Ramon Leon [mailto:[hidden email]]
> Sent: Tuesday, October 24, 2006 6:07 PM
> To: [hidden email]; 'The Squeak Enterprise Aubergines Server - general
> discussion.'
> Subject: RE: [Seaside] adding parameters to updater
>
>
> > Hi all,
> >
> > Any idea why this doesn't work?  Maybe I do not understand
> > updater.  I'm trying to make this as simple as possible so I
> > can see what it is doing?  It seems like it is working but
> > the javascript is not being evaluated once it is returned to
> > the browser.  Is there a way to see what ajax is returning?
>
> Bingo, you forgot to tell it to evalScripts!
>
> html div
>     id: 'ron';
>     onClick: (html evaluator callback: [ :script |
>         script element
>           id: 'ron';
> evalScripts: true;
>             addClassName: 'foo' ]);
>     with: 'hello'.
>
> Ramon Leon
> http://onsmalltalk.com
>


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

RE: RE: adding parameters to updater

Ron Teitelbaum
In reply to this post by Lukas Renggli
That was it, and it worked for IE too.  Thank you!  I read about the point
system in CSS too and I guess that makes sense.  Seems easy to make a
mistake though.  

Thanks very much for your help Lukas!

Ron

> From: Lukas Renggli
> Sent: Tuesday, October 24, 2006 6:07 PM
>
> > Any idea why this doesn't work?  Maybe I do not understand updater.  I'm
> > trying to make this as simple as possible so I can see what it is doing?
> It
> > seems like it is working but the javascript is not being evaluated once
> it
> > is returned to the browser.  Is there a way to see what ajax is
> returning?
> > Any ideas what I'm doing wrong?
>
> FireBug is the tool to use for any questions related to JavaScript:
> <https://addons.mozilla.org/firefox/1843/>
>
> For you particular problem this is rather a CSS problem than one of
> Scriptaculous. With the following code it works for me:
>
> #ron { background-color: green; }
> #ron.foo { background-color: red; }
>
> Note that there is no space between #ron.foo as these signifies the
> same element (this does not work in IE, to make it work there you
> presumably have to remove the #ron). Then there is also the order that
> matters in which the rules are specified (in your case it doesn't
> matter as classes go after id's, but just in general ...)
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch


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