2014-11-05 170 views
1

我正在制作一个将YouTube视频添加到播放列表的Web应用程序。选择显示在包含用户当前播放列表的视频缩略图旁边,当用户单击提交按钮时,应将当前视频添加到所选播放列表。但是,我遇到了回调似乎没有执行的问题。我很抱歉,如果答案是微不足道的,因为我无法看到的问题的根源:为什么没有执行回调? - Smalltalk

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'没有被打印到脚本中)。任何澄清,不胜感激。

+0

你在使用海边吗?你能用简单的形式重现问题并选择吗?为什么不使用'WASelectTag >>列表:'传递对象和'WASelectTag >>标签'来为每个元素指定标签块(更干净)。 – 2014-11-06 07:49:37

回答

2

因为with:块位于错误的地方。在Seaside中,with:是使用html画布时级联中的最后一条消息。

在一些更细节:

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 ] 

其中超是WABrush>>with:

WABrush>>with: 
    with: aBlock 
    canvas nest: aBlock. 
    closed := true 

通话所以回调永远不会写入服务器发送到浏览器的响应文件内。