passing additional parameters to an anchor callback

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

passing additional parameters to an anchor callback

Johan Brichau
Hi,

I am looking for a way to pass additional data in an anchor callback.  
Is that possible?

In the application I am building, there is a fair amount of javascript  
behavior on the client side and I often need to pass some javascript  
values when requests need to go back to the Seaside server  
application. In the particular code snippet below, I achieve this  
functionality by passing those values via an ajax call and have the  
callback block use those values. However, I'm not fond of that code  
since the values are required in the callback and not in the  
components themselves.

So my question is: can I make the callback block be called with values  
in the same way that I can pass on values to an ajax call (as in  
#callback:values:).
Or am I seeing this completely wrong and is there a better way?

html anchor
        onClick: (html jQuery ajax
                                trigger: [ :values | .... sets the values in the components ... ]
  passengers: (html jQuery ...));
        callback: [ ... does something that needs the values .... ];

----------------------------
Johan Brichau
[hidden email]




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

Re: passing additional parameters to an anchor callback

Lukas Renggli
Hi Johan

If you use a closure enabled Pharo image you might use method temps.
It also works in non-closure images but there you need to pass the
value through a value-holder.

Lukas

On Monday, October 5, 2009, Johan Brichau <[hidden email]> wrote:

> Hi,
>
> I am looking for a way to pass additional data in an anchor callback. Is that possible?
>
> In the application I am building, there is a fair amount of javascript behavior on the client side and I often need to pass some javascript values when requests need to go back to the Seaside server application. In the particular code snippet below, I achieve this functionality by passing those values via an ajax call and have the callback block use those values. However, I'm not fond of that code since the values are required in the callback and not in the components themselves.
>
> So my question is: can I make the callback block be called with values in the same way that I can pass on values to an ajax call (as in #callback:values:).
> Or am I seeing this completely wrong and is there a better way?
>
> html anchor
>         onClick: (html jQuery ajax
>                                 trigger: [ :values | .... sets the values in the components ... ]
>                                 passengers: (html jQuery ...));
>         callback: [ ... does something that needs the values .... ];
>
> ----------------------------
> Johan Brichau
> [hidden email]
>
>
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

--
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: passing additional parameters to an anchor callback

Johan Brichau
Hi Lukas,

You mean like the code below? That would indeed avoid to put the  
values in a component instance variable.
So there's no mechanism to pass those directly to the callback then? I  
assume that if the ajax call was not received (and answered) by the  
seaside application that the webbrowser will not execute the anchor  
link? (I should check that...)

Thanks for the suggestion!

| tempvalues |
html anchor
        onClick: (html jQuery ajax
                                trigger: [ :values | tempvalues :=  
values ]
                                passengers: (html jQuery ...));
        callback: [ ... does something with tempvalues .... ];

On 05 Oct 2009, at 21:56, Lukas Renggli wrote:

> Hi Johan
>
> If you use a closure enabled Pharo image you might use method temps.
> It also works in non-closure images but there you need to pass the
> value through a value-holder.
>
> Lukas
>
> On Monday, October 5, 2009, Johan Brichau  
> <[hidden email]> wrote:
>> Hi,
>>
>> I am looking for a way to pass additional data in an anchor  
>> callback. Is that possible?
>>
>> In the application I am building, there is a fair amount of  
>> javascript behavior on the client side and I often need to pass  
>> some javascript values when requests need to go back to the Seaside  
>> server application. In the particular code snippet below, I achieve  
>> this functionality by passing those values via an ajax call and  
>> have the callback block use those values. However, I'm not fond of  
>> that code since the values are required in the callback and not in  
>> the components themselves.
>>
>> So my question is: can I make the callback block be called with  
>> values in the same way that I can pass on values to an ajax call  
>> (as in #callback:values:).
>> Or am I seeing this completely wrong and is there a better way?
>>
>> html anchor
>>        onClick: (html jQuery ajax
>>                                trigger: [ :values | .... sets the  
>> values in the components ... ]
>>                                passengers: (html jQuery ...));
>>        callback: [ ... does something that needs the values .... ];
>>
>> ----------------------------
>> Johan Brichau
>> [hidden email]
>>
>>
>>
>>
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

----------------------------
Johan Brichau
[hidden email]




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

Re: passing additional parameters to an anchor callback

Lukas Renggli
> You mean like the code below? That would indeed avoid to put the values in a
> component instance variable.

Yes, but as I said, that only works with real closures.

> So there's no mechanism to pass those directly to the callback then? I
> assume that if the ajax call was not received (and answered) by the seaside
> application that the webbrowser will not execute the anchor link? (I should
> check that...)

You should not combine an AJAX and a traditional callback. They will
not be guaranteed to run in the right order. Instead do everything
with AJAX along these lines:

html anchor
    onClick: (html jQuery ajax
        trigger: [ :values | tempvalues := values ] passengers: ...;
        callback: [ ... does something with temps ... ];
        onSuccess: html javascript refresh);
    with: ...

Cheers,
Lukas

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