2014-11-05 221 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 

通話所以回調永遠不會寫入服務器發送到瀏覽器的響應文件內。