Re: Rendering Callbacks during an Ajax callback

"[email protected]" <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.squeak.seaside
Message-ID <[email protected]>
Hi Johan,

Am 11.02.17 um 10:51 schrieb Johan Brichau:
> Hi Joachim,
>
> Glad to hear you are decrypting all of this.
>
I hope my comment wasn't offending you. Just an expression of me not 
understanding immediately...
> Just to add: the code I sent really only does 1 ajax request from the 
> client to the server.
> The trick is that there are two callbacks attached to the same request.
So this is something I really need to understand, besides all those 
little alias:/access: and other helpers....
Maybe this time ;-)

>
> Of course, you can only attach a single callback that produces a 
> response (a primary callback).
> But you can attach as many secondary callbacks as you want (i.e. 
> callback:value or callback:passengers:) to a single ajax request.
I really need to play with this. So far, I tried doing as much as 
possible in hand-written JS because it is easier to read and debug than 
Seasides code-renderer-helpers. But as my case shows, there are 
situations in which you cannot get away with this approach...

>
> Have a nice weekend!
Same to you. You've had your Seaside Doctor's shift today ;-)

Joachim

> Johan
>
>> On 11 Feb 2017, at 10:41, [email protected] 
>> <mailto:[email protected]> wrote:
>>
>> Hi Johan
>>
>>
>> Am 11.02.17 um 10:19 schrieb Johan Brichau:
>>> Hey Joachim,
>>>
>>> You can use a normal seaside callback and register it to capture 
>>> delegated events.
>>> No magic ;)
>>>
>>> html orderedList
>>> script: (html jQuery this
>>> on: ‘click’
>>> selector: ‘.mylistItemClass’
>>> do: ((html jQuery ajax
>>> callback: [:listitemId |  … ]
>>> value: (((html javascript alias: ‘event’) access: ‘target’) access: 
>>> ‘id’))
>>> asFunction: #(event))
>>>
>>> This registers the callback on the list to capture clicks on the 
>>> items below it, while passing the id of the element on which the 
>>> click happened to the callback.
>>> If you register passengers on each of the listitems, it’s more 
>>> intuitive:
>>>
>>> html orderedList
>>> script: (html jQuery this
>>> on: ‘click’
>>> selector: ‘.mylistItemClass’
>>> do: ((html jQuery ajax
>>> callback: [:passenger |  … ]
>>> passengers: ((html javascript alias: ‘event’) access: ‘target’)
>>> asFunction: #(event))
>>>
>>> Obviously, this does not render anything yet. So, we need to add 
>>> that functionality to the callback:
>>>
>>> | idToReRender |
>>> html orderedList
>>> script: (html jQuery this
>>> on: ‘click’
>>> selector: ‘.mylistItemClass’
>>> do: ((html jQuery ajax
>>> callback: [:listitemId |  … idToReRender := listitemId ... ]
>>> value: (((html javascript alias: ‘event’) access: ‘target’) access: 
>>> ‘id’));
>>> script: [:s | s << ((s jQuery id: idToReRender) html: [:h | self 
>>> renderMyRowWithId: idToReRender ]) ]
>>> asFunction: #(event))
>>>
>> I seem to understand. This will call the server twice, once for the 
>> setting id of which item to rerender, and a second time for the 
>> actual rendering, right? My attempt tried to use the first ajax 
>> callback to do both: process the business code and answer the 
>> re-rendered row to the client, so that it just does a .replaceWith() 
>> for the row with the re-rendered one. That is why I needed to have a 
>> builder that the component could render itself onto.
>>
>> But since your aproach  just registers one single callback for the 
>> whole list, it still is an improvement compared to registering the 
>> very same callback for each row - which takes a lot of time on both 
>> the server and the client. And apart from the double ajax calls, it 
>> is exactly what I want to achieve. I guess my reason for hand-written 
>> javascript here is that I like to be able to debug it and I know way 
>> too little about JQAjax' many options... time to study
>>
>> My brain is working on this, and I am really grateful for your time 
>> and help. I guess we should negotiate your reward in Maribor ;-)
>>
>>
>> Joachim
>>
>>
>> -- 
>> -----------------------------------------------------------------------
>> Objektfabrik Joachim Tuchelmailto:[email protected]
>> Fliederweg 1http://www.objektfabrik.de
>> D-71640 Ludwigsburghttp://joachimtuchel.wordpress.com
>> Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1
>>
>> _______________________________________________
>> seaside mailing list
>> [email protected] 
>> <mailto:[email protected]>
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
>
> _______________________________________________
> seaside mailing list
> [email protected]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


-- 
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          mailto:[email protected]
Fliederweg 1                         http://www.objektfabrik.de
D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1

_______________________________________________
seaside mailing list
[email protected]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.