[Seaside] Updating multiple elements when a multi-select changes
Paul Price
paul at unitmath.com
Sun Mar 16 03:29:43 UTC 2008
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.
More information about the seaside
mailing list