[Seaside] jQuery onChange: and onKeyPress:

bobn at rogers.com bobn at rogers.com
Wed Jan 9 14:58:11 UTC 2013


Hello,
I would like to combine the use of onChange: and onKeyPress: to display 'Save' & 'Cancel' buttons.

onChange: is useful when a value is pasted in to the text field, and onKeyPress: shows the buttons without having to click elsewhere. So far this is working well, except when the first component selected after entering text is the 'Save' or 'Cancel' button. When that happens, the onChange: action is triggered, which re-renders the button. From the user's perspective, the button press was ignored and needs to be done again.

I would like to have the onKeyPress: action remove the onChange: behaviour.  How can that be done?
Or is there a better way to detect that text was pasted in? (i.e. cases where onKeyPress: is not triggered).

Here is some sample code... 
If you enter a value into the text input field and then press the button, you'll notice the ignored button press.

renderContentOn: html

html form: [
html text: 'Message text:'.
html textInput
value: self messageText; 
onChange: (html jQuery ajax callback: [:inputValue | self messageText: inputValue] value: html jQuery this value);
onChange: ((html jQuery id: 'showThis') load html: [:renderer | self renderMessageTextAndButtonOn: renderer]);
onKeyPress: (html jQuery ajax callback: [:inputValue | self messageText: inputValue] value: html jQuery this value);
onKeyPress: ((html jQuery id: 'showThis') load html: [:renderer | self renderMessageTextAndButtonOn: renderer]);
yourself.
html horizontalRule.
html div id: 'showThis'; with: [
self renderMessageTextAndButtonOn: html]]


renderMessageTextAndButtonOn: html



html button callback: [Transcript cr; show: 'Button pressed']; with: 'Press'.
html break.
html text: self messageText asString


Thanks, 
Bob Nemec
HTS Engineering
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20130109/080d5b9b/attachment.htm


More information about the seaside mailing list