2012-05-16 44 views
1

我用jQuery自動完成jQuery的自動完成信號源功能要求發送方

工作,我試圖讓誰稱爲源值

我用一個函數來獲取我的列表控制(發件人)。

類似的東西(的樣子):

$("#input").autocomplete({ 
    source: function (request, response) { 
     $.post("/AjaxPostURL", request, response); 
    } 
}); 
sample From : http://stackoverflow.com/questions/1512607/how-do-i-set-jquery- 

自動完成對後INSTEAD-OF-得到

但是我的是一個外部函數

我要趕控制我的職責是這樣

一點內幕(的樣子):

$("#input").autocomplete({ 
     source: myfunction (this) 
     } 
    }); 

myfunction = function (request, response, control) { 
      $.post("/AjaxPostURL", request, response); 
      control.xxx 
} 

我需要保留請求和響應。但我也需要控制誰調用函數。

我該怎麼做?

坦克你


第2部分

我認爲它應該像

source: function(event, ui) {  
     myfunction(event,ui ,$(this)); 
     } 

問題:$這不存在在這個時候。只有在調用該函數時纔會設置該參數。 和它的未定義我的功能(當shes叫)。

回答