Seaside:列表在更新时丢失其内容
这个其实很简单。我有一个
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
).
]
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
).
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
#updater
需要要更新的元素的 DOM ID。如果您未能提供 ID,则默认为this
,即触发事件的 DOM 元素。因此,您最终会得到一个空列表。如果您不需要更新某些内容,则应使用#request
而不是#updater
。如果您想更新某些内容,则需要使用#id:
提供有效的 ID。阅读 Seaside Book 的AJAX:与服务器对话部分,它非常详细地解释了 AJAX。
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.
因为更新程序用回调生成的内容替换了定义它的元素的 html,并且您的回调不会生成任何 html,所以我认为该列表是空的。
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.