[Seaside] ajax onBlur callback with load html

Paul DeBruicker pdebruic at gmail.com
Tue Sep 14 14:14:16 UTC 2021


Forum.world.st no longer updates from the mailing lists. The nabble platform it's built on stopped supporting mailing lists. 

So now the only updated archives are at 

http://lists.squeakfoundation.org/pipermail/seaside/




> On Sep 14, 2021, at 5:42 AM, Bob Nemec <bobn at rogers.com> wrote:
> 
> 
> (sorry if this is duplicate; didn't see the first attempt in the email list)
> 
> I have a design pattern question: what is the good way to deal with ajax callbacks when the component is refreshed by a previous component’s onBlur action, using jQuery load html: […]? 
> 
> We use onBlur to get the data from input fields and to refresh the state of the view. The problem comes up if a button is included in the refresh: the ajax callback from that button is not handled (which makes sense due to the jQuery load), so the user has to press the button again. 
> 
> To get around this we’re selective about which components we refresh, but it feels like there should be a better way. 
> 
> Here is a simple example (coded in VW), where #stringValue is an instVar. Entering a value and triggering the onBlur will show the ' value: ' in the Transcript, but pressing the button will not show the ' button: ' string until the second press, since the onBlur happens before the button callback and the onBlur is rendering the button again. If the button is rendered outside of the 'testDiv' it works fine...
> 
> renderContentOn: html 
> 	html div id: 'testDiv'; with: [
> 		self renderContentDivOn: html]
> 
> renderContentLoadDivOn: html
> 	^(html jQuery id: 'testDiv') load html: [:renderer | 
> 		self renderContentDivOn: renderer]
> 
> renderContentDivOn: html 
> 	html text: 'Test at ' , Time now displayString.
> 	html horizontalRule. 
> 	html textInput 
> 		value: self stringValue; 
> 		onBlur: (
> 				(html jQuery ajax callback: [:value | 
> 						self stringValue: value.
> 						Transcript cr; show: Time now printString , ' value: ' , value asString]
> 				value: (html jQuery this value) ) 
> 			onSuccess: (self renderContentLoadDivOn: html) ).
> 	html break; break. 
> 	html button 
> 		onClick: ( 
> 				(html jQuery ajax callback: [
> 					Transcript cr; show: Time now printString, ' button: ' , self stringValue asString])
> 			onSuccess: (self renderContentLoadDivOn: html) );
> 		with: 'Press'
> 
> Thanks for any advice,
> Bob Nemec
> KORE / HTS
> 
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/seaside/attachments/20210914/b2e2e667/attachment-0001.html>


More information about the seaside mailing list