Updating multiple elements when a multi-select changes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Updating multiple elements when a multi-select changes

Paul Price
Two questions:
ONE:  How do I trigger the form and set multiple text fields in onClick: ?
TWO:  How do I set multiple text fields in the callback: ?

   Sorry to ask this question, I read many of the last posts
(including most with #evaluator), and all the tutorials I could find,
but I'm stuck.


Details:
   I'm trying to get preferences for my program. I have four check boxes
 and three multi select controls. The controls are interrelated and I want
 the user to clearly see the what's going on.  Therefore when one control
changes the examples for other controls must change.

   I started with the code from SUFormTest and was fairly quickly able to
 get this kind of result.

'Decimal Digits'.    0-9{7}    pi ~ 3.1415927
Exponential Notation  Y/N{Y}    1234567 = 1.234567e6

and when I changed the digits multi-select to 1 I see
'Decimal Digits'.    0-9{1}    pi ~ 3.1
Exponential Notation  Y/N{Y}   1234567 = 1.234567e6

and what I want to see is
'Decimal Digits'.    0-9{1}    pi ~ 3.1
Exponential Notation  Y/N{Y}   1234567 = 1.2e6

BASE CODE
  renderContentOn: html
 html div class: 'lightbox';
  with: [html div class: 'title';
    with: [html text: '...'].
   html
    table: [self
       renderScentificNotationOn: html;
       ...
       renderDecimalDigitsOn: html];
    form: [html submitButton text: 'OK';
      callback: [self answer: self].
     html submitButton text: 'Cancel';
      callback: [self answer: nil]]]

renderDecimalDigitsOn: html
 | modelId formId |
 formId := 'Decimal Digits Form'.
 modelId := 'Decimal Digits Model'.
 html div class: 'row';
  with: [html div class: 'label';
     with: 'Decimal Digits'.
   html div class: 'control';
    with: [html div class: 'control';
      with: [html form id: formId;
       with: [html select
         list: (0 to: 9);
          selected: self unitMathPreferencesModel displayDigits;
         callback: [:value |
          self unitMathPreferencesModel displayDigits: value.
          self setExamples.];
          onClick: (html updater id: modelId;
           triggerForm: formId;
          callback: [:r | r render: digitsEx])]]].
  html div class: 'model';
    id: modelId;
    with: digitsEx.
  html div class: 'clear'].

{The callback is triggered and the 'model' text is changed.  
( digitsEx is set in the method setExamples. )}

 Code II
Changing the on onClick: to

 onClick: ((html evaluator
   callback: [:script |
    script element id: modelId;
      render: 'test ' , digitsEx.
   script element id: 'Show Exp Model';
      render: 'test # changed digits' , sciNotEx])

{Both the exp and digits models changed, so I can change the text in
 multiple places in response to the action, but the form was not
triggered.}

Now I need to trigger the form, and set the values. I'm at a loss.
How do I do this?

 I tried
Code III

 onClick: (html evaluator
    callback: [:script |
      script canvas updater triggerForm: formId.
      script element id: modelId;
        render: 'test ' , digitsEx.
   script element id: 'Show Exp Model';
     render: 'test # changed digits' ,
    sciNotEx])

{Both the exp and digits models changed to test, but the form
did not trigger, and the digits did not change.}

I have tried may options around script canvas updater triggerForm:
formId, and none work.

I then reverted back to the first onClick: and tried to set the other
values in the callback.

callback: [:value |
 self unitMathPreferencesModel displayDigits: value.
  self setExamples.
 html element id: 'Show Exp Model';
   render: 'test # changed digits' , sciNotEx];
   onClick: (html updater id: modelId;
   triggerForm: formId;

  callback: [:r | r render: digitsEx])]]].

{ The sciNotEx is never updated }

I tried many options around html element, but none worked.

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Updating multiple elements when a multi-select changes

Lukas Renggli
>   onClick: (html evaluator
>     callback: [:script |
>       script canvas updater triggerForm: formId.
>       script element id: modelId;
>         render: 'test ' , digitsEx.
>    script element id: 'Show Exp Model';
>      render: 'test # changed digits' ,
>     sciNotEx])

Why do you have a special updater inside the evaluator? I guess it
would make more sense to have "triggerForm: formId" directly with the
evaluator.

>    Sorry to ask this question, I read many of the last posts
>  (including most with #evaluator), and all the tutorials I could find,
>  but I'm stuck.

Other than that, please read:

   http://www.seaside.st/community/mailinglist

Post a working one-click file-out, and not a long mail full of code
snippets. I don't have the time to spend hours trying to reproduce
your situation.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Updating multiple elements when a multi-select changes

Paul Price
Lukas Renggli <renggli <at> gmail.com> writes:

>
> >   onClick: (html evaluator
> >     callback: [:script |
> >       script canvas updater triggerForm: formId.
> >       script element id: modelId;
> >         render: 'test ' , digitsEx.
> >    script element id: 'Show Exp Model';
> >      render: 'test # changed digits' ,
> >     sciNotEx])
>
> Why do you have a special updater inside the evaluator?

Because it is the only way I have seen to trigger a from.

>I guess it
> would make more sense to have "triggerForm: formId" directly with the
> evaluator.

Yes, my question is how do to do that given the script variable and the formId?

>
> >    Sorry to ask this question, I read many of the last posts
> >  (including most with #evaluator), and all the tutorials I could find,
> >  but I'm stuck.
>
> Other than that, please read:
>
>    http://www.seaside.st/community/mailinglist

Thank You, I have, and will continue to.

>
> Post a working one-click file-out, and not a long mail full of code
> snippets. I don't have the time to spend hours trying to reproduce
> your situation.
>
> Lukas
>

Sorry I don't know how to post a working one-click file-out.
Thank you for taking the time to respond.

Paul


Other things I've tried to trigger the form in onClick:.

script triggerForm: formId.                                    
          debugger SUScript does not understand triggerForm:
script canvas triggerForm: formId.                      
             debugger WARenderCanvas does not understand triggerForm:

The following do not throw a debugger, but also don't trigger the form.
script updater triggerForm: formId.
script canvas updater triggerForm: formId.
script canvas updater triggerForm: formId.
script canvas updater id: modelId;  triggerForm: formId
html updater id: modelId; triggerForm: formId.
script element updater id: modelId; triggerForm: formId.
script element canvas updater id: modelId; triggerForm: formId.





_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Updating multiple elements when a multi-select changes

Paul Price
Paul Price <paul <at> unitmath.com> writes

>
> Lukas Renggli <renggli <at> gmail.com> writes:
> >
> > >   onClick: (html evaluator
> > >     callback: [:script |
> > >       script canvas updater triggerForm: formId.
> > >       script element id: modelId;
> > >         render: 'test ' , digitsEx.
> > >    script element id: 'Show Exp Model';
> > >      render: 'test # changed digits' ,
> > >     sciNotEx])
> >
> > Why do you have a special updater inside the evaluator?
>
> Because it is the only way I have seen to trigger a from.
>

The following works.  

html evaluator triggerForm: formId;
callback: [:script |
script element id: modelId;
 render: 'test ' , digitsEx.
script element id: 'Show Exp Model';
render: 'test # changed digits' , sciNotEx]

Thanks for your time Paul





_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Re: Updating multiple elements when a multi-select changes

Lukas Renggli
> The following works.
>
>  html evaluator triggerForm: formId;
>  callback: [:script |
>
> script element id: modelId;
>   render: 'test ' , digitsEx.
>  script element id: 'Show Exp Model';
>  render: 'test # changed digits' , sciNotEx]

Exactly. Sorry if I was not clear. All those triggers are defined in
the abstract SUAjax class, which is the superclass of SUUpdater,
SUEvaluator, SURequestor, etc.

Glad it works.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside