[Seaside] jQuery variable check for onBlur

bobn at rogers.com bobn at rogers.com
Wed Apr 10 13:38:50 UTC 2013


Excellent, it worked great... 

onSuccess: (
    (Javascript.JSStream on: 'saveCancelButtonClicked == 0') then: (
(html jQuery id: 'portalSelectedComponent') load html: [:renderer | 


...the method that renders the save and cancel buttons contains...
html script: 'saveCancelButtonClicked = 0;' .

...both the save and cancel buttons implement...

onMouseDown: 'saveCancelButtonClicked = 1;'; 


...works just as I wanted: pressing either the 'Save' or 'Cancel' button after updating an input field triggers the callback on the first click. 
And losing focus triggers the input field onBlur action normally. 

Thanks,
Bob



________________________________
 From: "jtuchel at objektfabrik.de" <jtuchel at objektfabrik.de>
To: seaside at lists.squeakfoundation.org 
Sent: Wednesday, April 10, 2013 9:21:52 AM
Subject: Re: [Seaside] jQuery variable check for onBlur
 
Hi again,

without having tested it, this may look something like

onSuccess: (
     (JSStream on: 'saveCancelButtonClicked == 1')
       then: ((html jQuery id:  'selectedComponent')  load html: 
[:renderer|  self  renderSelectedComponentOn:  renderer]))
       else: ....)

Please let us know how the code ends up looking once you solved. I'd be 
very interested to learn more about this.

Joachim


Am 10.04.13 15:09, schrieb jtuchel at objektfabrik.de:
> 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
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

_______________________________________________
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/20130410/bd219166/attachment-0001.htm


More information about the seaside mailing list