简体   繁体   中英

Why is the callback not being executed?

I'm writing a basic web application (begin with seaside) but the callback never runs...any ideas?

renderContentOn: html

  | group |
  html form: [

    html text: 'Gender: '.
    group := html radioGroup.
    group radioButton
        selected: self contact isMale;
        callback: [ self contact beMale ].
    html text: 'Male'.
    group radioButton
        selected: self contact isFemale;
        callback: [ self contact beFemale ].
    html text: 'Female'.
    html break.

    html anchor
    callback: [ mmpiItems setAnswer: (self option) ];
    with: 'Next'.
 ]

An anchor inside the form does not submit the form, only a submitbutton does. This is not defined by Seaside but by HTML.

You can find more information in the seaside book on writing forms with Seaside: http://book.seaside.st/book/fundamentals/forms

You must use submitButton instead of an anchor or any other button .

Your code would look like this:

renderContentOn: html

 | group |
 html form: [
   html text: 'Gender: '.
   group := html radioGroup.
   group radioButton
     selected: self contact isMale;
     callback: [ self contact beMale ].
   html text: 'Male'.
   group radioButton
     selected: self contact isFemale;
     callback: [ self contact beFemale ].
   html text: 'Female'.
   html break.
   "Use a submitButton instead of a regular anchor/button"
   html submitButton
     callback: [ mmpiItems setAnswer: (self option) ];
     with: 'Next'.
   ]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM