AJAX evaluator and javascript

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

AJAX evaluator and javascript

squeakman
Greetings,

I am trying to do the following:
on the client browser, when the user clicks on something, I would like
to use the "html evaluator" to send a bit of javascript code back to the
client and execute the javascript code.

Here is the code that I have:

html div id: 'foo';
        onClick: (html evaluator
                callback: [:script |
                        script add: 'var bar ="This is a test"'.
                        script call: 'alert' argument: 'bar']);
        with: 'Show Alert'.

What I am expecting is a Javascipt alert to pop up. What am I doing wrong?

Thanks,
Frank

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

Re: AJAX evaluator and javascript

Lukas Renggli
>  What I am expecting is a Javascipt alert to pop up. What am I doing wrong?

Have a look at the JavaScript code that is sent back in FireBug or the
Safari Console.

The problem is that when you use 'strings' in Smalltalk you get
strings in JavaScript. No magic here. So 'var bar = "This is a test"'
is a string. Not a variable declaration.

You might want to try:

    script alert: 'This is a test'

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: AJAX evaluator and javascript

squeakman
Lukas Renggli wrote:

> The problem is that when you use 'strings' in Smalltalk you get
> strings in JavaScript. No magic here. So 'var bar = "This is a test"'
> is a string. Not a variable declaration.
>
> You might want to try:
>
>     script alert: 'This is a test'
>
> Cheers,
> Lukas
>

What I am really trying to get at is how do I reference a javascript
variable from within the callback of the html evaluator.

If I assume that there is an existing javascript variable called "bar",
how to I get the evaluator to generate "alert(bar)"

Thanks,
Frank

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

Re: Re: AJAX evaluator and javascript

Lukas Renggli
>  What I am really trying to get at is how do I reference a javascript
> variable from within the callback of the html evaluator.
>
>  If I assume that there is an existing javascript variable called "bar", how
> to I get the evaluator to generate "alert(bar)"

script alert: (SUStream on: 'bar')

Have a look at SUScript>>#alert:, this is an example on how to
generate verbatim output.

Cheers,
Lukas

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