onClick vs callback

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

onClick vs callback

Tomas Blazej
Hello,

I have a problem with the submitButton. It is placed in the component and in the form. It has callback, which contains only answer: call for this component.

But I also need some javascript in onClick event generated by evaluator.

The problem is, that the javascript code from onClick seems to be executed only if I call "return: false" for the evaluator. But in this case, the callback of the button is not run :(

"return: false" with triggerForm(Element): doesn't work.. Is the answer evaluated before the javascript and then it doesn't make sense or is there any other problem..?

Thank you,
Tomas

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

Re: onClick vs callback

Lukas Renggli
> But I also need some javascript in onClick event generated by evaluator.

This is AJAX and the A is for asynchronous. This means the evaluator
will return immediately after having set off a request in a background
thread. If you change to a different page right away, the background
request is aborted/ignored.

> The problem is, that the javascript code from onClick seems to be executed
> only if I call "return: false" for the evaluator. But in this case, the
> callback of the button is not run :(

"return: false" tells the browser *not to perform* the callback.

> "return: false" with triggerForm(Element): doesn't work.. Is the answer
> evaluated before the javascript and then it doesn't make sense or is there
> any other problem..?

You can tell your evaluator not to be asynchronous using
"asynchronous: false". However consider the comment for this method:
"Determines whether XMLHttpRequest is used asynchronously or not.
Since synchronous usage is rather unsettling, and usually bad taste,
you should avoid changing this. Seriously."

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: onClick vs callback

Tomas Blazej
Thank you, "asynchronous: false" worked!

I also found that this happened only in firefox, in IE it works even without setting it to behave synchronously..

Tomas

2008/2/7, Lukas Renggli <[hidden email]>:
> But I also need some javascript in onClick event generated by evaluator.

This is AJAX and the A is for asynchronous. This means the evaluator
will return immediately after having set off a request in a background
thread. If you change to a different page right away, the background
request is aborted/ignored.

> The problem is, that the javascript code from onClick seems to be executed
> only if I call "return: false" for the evaluator. But in this case, the
> callback of the button is not run :(

"return: false" tells the browser *not to perform* the callback.

> "return: false" with triggerForm(Element): doesn't work.. Is the answer
> evaluated before the javascript and then it doesn't make sense or is there
> any other problem..?

You can tell your evaluator not to be asynchronous using
"asynchronous: false". However consider the comment for this method:
"Determines whether XMLHttpRequest is used asynchronously or not.
Since synchronous usage is rather unsettling, and usually bad taste,
you should avoid changing this. Seriously."

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: onClick vs callback

Lukas Renggli
> I also found that this happened only in firefox, in IE it works even without
> setting it to behave synchronously..

That depends on the scheduling algorithm of the JavaScript engine.
Generally all AJAX requests run asynchronously, therefor it is not
possible to give any guarantees when and if a response is coming back.
That's why there are callback handlers, such as #onCompleted:,
#onFailed:, #onSuccess:, etc.

Lukas

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