Seaside: list losing its content on update

227 views Asked by At

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
                ).
    ]
2

There are 2 answers

0
Lukas Renggli On BEST ANSWER

The #updater needs an DOM ID of the element to update. If you fail to provide an ID, it default to this, 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.

0
Richard Durr On

Because the updater replaces the html of the element it was defined on with the content generated by the callback and your callback does not generate any html, the list is empty, I think.