[Seaside] Jquery select then hide

Bob Arning arning315 at comcast.net
Sun Apr 26 22:57:00 UTC 2015


This works for me:

renderXYZ02: html

     | s1 choiceMade |

     choiceMade := '?'.
     html form
         with: [
             html div
                 id: 'maiden';
                 style: 'display: none';
                 with: [
                     html text: 'Enter maiden name'
                 ].

             s1 := html jQuery ajax
                 callback: [ :value |
                     choiceMade := value.
                 ]
                 value: (JSStream on: 'options[selectedIndex].text');

                 script: [ :s |
                     choiceMade = 'miss'
                         ifTrue: [s << (s jQuery: #maiden) show]
                         ifFalse: [s << (s jQuery: #maiden) hide]
                 ].

             html select
                 list: #('mr' 'ms' 'miss');
                 beOptional;
                 onChange: s1;
                 selected: nil.
         ].


On 4/26/15 5:47 PM, Hilaire wrote:
> Hi,
>
> A classic problem I can't get through: Depending on a select answer I
> want to hide or show a node in the DOM tree.
>
> So far I try this with mixed result:
>
>
>              (field := mold at: #civility) "a select tag"
>                      onChange: [ :aHtml | aHtml jQuery ajax serialize:
> aHtml jQuery this];
>                      customize: [:selectTag | "just set the seside
> callback to the select tag"
>                          selectTag callback: [: val |
>                              field input: val.
>                              html jQuery ajax script: [ :s |
>                                  val == #miss
>                                      ifTrue: [s << (s jQuery: #maiden) show]
>                                      ifFalse: [s << (s jQuery: #maiden)
> hide]]
>                              ]
>                          ].
>     
>
> The serialize part work (it took me some time to realize
> jQuery>>serialize does not much, but JAjax>serialize runs the form callback)
> The script part does not work. What I am mssing?
>
>
> A question about load: is it about updating a node with refreshed html
> rendering from the server?
>
>
> Thanks
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20150426/c0f086a6/attachment-0001.htm


More information about the seaside mailing list