[Seaside] jQuery variable check for onBlur

jtuchel at objektfabrik.de jtuchel at objektfabrik.de
Wed Apr 10 13:09:53 UTC 2013


Hi Bob,

I guess what you are looking for is JSIfThenElse. I have no example at 
hand, but remember two things about it:
* It feels strange to send then:else: to a JSObject. Not very Smalltalkish.
* It does have a bug that I reported on this list a long time ago. It 
only renders the (if) ? then : else; form. So you should change 
#javascripContentOn: to

javascriptContentOn: aStream
     aStream nextPutAll: 'if('.
     super javascriptContentOn: aStream.
     aStream nextPutAll: ') {'.
     aStream javascript: self trueStatement.
     aStream nextPutAll: '} else {'.
     aStream javascript: self falseStatement.
     aStream nextPut: $}.

for more complex statements.

In your case, what you need to do first is produce a JSObject that 
represents the results of the client-side check "saveCancelButtonClicked 
== 1" and send it #then: or #then:else. I'd be interested in how you can 
create that JSObject... I guess it's easy....

Joachim


Am 10.04.13 14:59, schrieb bobn at rogers.com:
> I posted this on Stack Overflow... no answer so far:
> How do I code a variable check into a Seaside jQuery onSuccess: script?
> I have an application with input fields that trigger a value change 
> followed by a re-rendering of the view. It works nicely to provide 
> lively feedback of domain data based on displayed values.
> The view shows 'Save' and 'Cancel' buttons if there are changes 
> pending. If the user clicks on either button right after an input 
> field, the onBlur: script of the input fields prevents the button 
> action from taking place. The recommended solution (button click event 
> lost due to the alert box in text box onblur event 
> <http://stackoverflow.com/questions/3245350/button-click-event-lost-due-to-the-alert-box-in-text-box-onblur-event>) 
> is to use the button's 'onmousedown' event to set a global variable 
> that the onBlur script checks.
> With my test code I can see the global 'saveCancelButtonClicked' being 
> set, but I don't know how to check the value in order to prevent the 
> rendering step.
> |html button
>    onMouseDown:  'saveCancelButtonClicked = 1;';  
>    ...
>
> html textInput
>   onBlur:  ((
>    html jQuery ajax
>        callback:  [:stringValue|  self  checkValue:  stringValue]  
>            value:  html jQuerythis  value)
>        onSuccess:  (
>          (html jQuery id:  'selectedComponent')  load html:  [:renderer|  
>            renderer script:  'console.log(saveCancelButtonClicked);'.
>            self  renderSelectedComponentOn:  renderer])  )]|
> I can see the console.log showing '1' if the save button is pressed. 
> So how do I check the value and skip the 'self 
> renderSelectedComponentOn:' step?
> It's easy enough to do in javascript (trivial if statement), but I 
> have not found an example in Seaside.
> Thanks for any help,
> Bob Nemec
>
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



More information about the seaside mailing list