This one is really simple. I've got a <select>
and I want to update some internal state based on the selection. No need to redisplay anything. The problem is that after the selection and the AJAX request have been made, the list loses its contents.
renderContentOn: html
|value myId|
html form with: [
html select list: #('one' 'two' 'tree' 'four' 'five');
id: (myId := html nextId);
callback: [ :v | value := myId ];
onChange: (
html prototype updater
triggerFormElement: myId;
callback: [:h | value "do something with the value here"];
return: false
).
]
The
#updater
needs an DOM ID of the element to update. If you fail to provide an ID, it default tothis
, the DOM element triggering the event. Thus, you end up with an empty list. If you do not need to update something you should use#request
instead of#updater
. If you want to update something you need to provide a valid ID using#id:
.Read the section AJAX: Talking back to the Server of the Seaside Book, it explains AJAX in great detail.