我正在制作一个网络应用程序,将YouTube视频添加到播放列表中。选择显示在包含用户当前播放列表的视频缩略图旁边,当用户单击提交按钮时,当前视频应添加到所选播放列表中。然而,我遇到了一个问题,回调似乎没有执行。如果答案微不足道,我深表歉意,因为我看不出问题是从哪里来的:
html form with:
[html select with:
self session getPlaylists keysDo:
[:k | html option value: k; with: [html text:k]]];
callback: [:v | self session addVideo: ((searchRes at: 'items')
at: (i*2+x)) toPlaylist: v. Transcript show: 'call'].
html break.
html submitButton class:'tiny button';value: 'Add to Playlist']
抱歉,代码太乱了。基本上,回调没有执行(我知道这一点,因为在提交表单时,"call"没有打印到记录中)。如有任何澄清,不胜感激。
因为with:
块位于错误的位置。在Seaside中,当使用html画布时,with:
是级联中的最后一条消息。
更详细地说:
WATagBrush>>with: anObject
"Render anObject into the receiver. Make sure that you call #with: last in the cascade, as this method will serialize the tag onto the output document."
self openTag.
super with: [
self before.
canvas render: anObject.
self after ].
self isClosed
ifFalse: [ self closeTag ]
其中super是对WABrush>>with:
的调用
WABrush>>with:
with: aBlock
canvas nest: aBlock.
closed := true
因此,回调永远不会写在服务器发送到浏览器的响应文档中。