[Seaside] Re: Differences in calling render: from ajax?

Tim Mackinnon tamackinnon at gmail.com
Thu Aug 12 12:01:40 UTC 2010

On 2010-08-12 08:41:38 +0100, Johan Brichau said:
> Do you mean that the second html snippit is the replacement that 
> isgenerated when you click the button (and have the replace 
> scriptexecuting) ?

Yes the 2nd snippet is the replacement generated on the click and it is 
missing the s,k params (refreshing the whole page restores them)
> I notice that you are not using the s parameter in your ajax 
> scriptcallback. Where are you calling the #ajaxReplaceWith: method? Is 
> this inthe #removeToken: method? And how are you constructing the 
> aJSQuery?

I am reacting to a model change announcement (whose source is from 
another ajax call - the button click to remove an item), so the chain 
looks like this:

	self pusher javascript: [ :jsScript | jsScript << (self 
generateUpdateScriptWith: jsScript jQuery) ]

generateUpdateScriptWith: aJQuery
	^(self waitersView ajaxReplaceWith: aJQuery) , (self holderView 
ajaxReplaceWith: aJQuery)

then both components inherit the following:

ajaxReplaceWith: aJSQuery
	^ (aJSQuery id: myId) replaceWith: [ :r | r render: self ]

> My guess is that you hit a problem that is identical to the 
> onementioned in the 'important' box 
> here:http://book.seaside.st/book/web-20/scriptaculous/ajax/updating
> If you are generating another ajax callback, the renderContext (and 
> thusactionUrl, etc...) are wrong.

I think you are right - but from the above I am passing on a fresh 
JQuery object, and then using it to do the double dispatch on the 
render call?

I think this is related to your? comet thread - it feels like there is 
a neat way to do this, but I haven't got my head around it yet. The 
above all worked fine until I had to render new callbacks into the code 
for my buttons.

I'm not sure what line of attack to experiment with next?


> On 12 Aug 2010, at 01:17, Tim Mackinnon wrote:
>> So I was making great progress until I descided to render removebuttons 
>> with items in my subcomponent.
>> When I initially render my component I have something like this:
>> renderContentOn: html
>> 	(html div)
>> 	     self contentModel tokenWaitersDo: [ :item | html tableRow:[ 		i := i + 1.
>> 		html 		   tableData: [ html text: item name ];
>> 		   tableData: [html button 												onClick: (htmljQuery ajax 
>> script: [:s| self removeToken: i]); 						value: 'Remove' ] ] ] ] ] ]
>> And I get something in my page like this:
>> <button class="submit" 
>> type="submit"onclick="$.ajax({&quot;dataType&quot;:&quot;script&quot;,&quot;url&quot;:&quot;/elephant&quot;,&quot;data&quot;:[&quot;_s=6EHJpgKqpOIhEcqM&quot;,&quot;_k=ICZ-_7Df8kBvKt2F&quot;,&quot;3&quot;].join(&quot;&amp;&quot;)})">Remove</button>

>> click on my remove button - I end up doing something like:
>> ajaxReplaceWith: aJSQuery
>> 	^ (aJSQuery id: myId) replaceWith: [ :r | r render: self ]
>> But it generates the following:
>> <button class="submit" 
>> type="submit"onclick="$.ajax({&quot;dataType&quot;:&quot;script&quot;,&quot;url&quot;:&quot;/&quot;,&quot;data&quot;:&quot;1&quot;})">Remove</button>

>> I picked up the above fragment from some mal message answer byLukas - 
>> and it was working well, but notice how the url parameter iswrong - its 
>> not /element with the k and s paramters???
>> Is this because render: is not rendering in the context of a 
>> childcomponent? And is there some other way of re-rendering my 
>> component byan ajax call? I think Julian had an example in the comet 
>> thread - maybeI can get that to work?
>> Any help greatly appreciated.
>> Tim
>> _______________________________________________
>> seaside mailing list
>> seaside at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

More information about the seaside mailing list