0
我打電話給遠程數據源並取回json。在我選擇一個項目後,select:
回調選項只允許我處理項目的標籤和值,但我還想使用我的json對象的其他屬性來自動填充其他字段。選擇jQuery自動完成填寫其他字段
有沒有一個方便的方法來做到這一點,我失蹤了?我看到到目前爲止是選項...
- 緩存全局Ajax響應JSON對象和參考選擇
- 重新查詢後這個全局對象使用該項目的價值或標籤
對這些都不是特別滿意。思考?
編輯 我忘了我是用$ .MAP
$('#accountName').autocomplete({
source: function (request, response) {
$.getAccountsByNameLike(request.term, function (data) {
response($.map(data, function (item) {
return {
label: item.Name + ' (' + item.Address.City + ', ' + item.Address.StateOrProvince + ')',
value: item.AccountId,
// Added to fix issue
raw: item
}
}));
}, function (error) {
// async kickoff a log to logging server service...
alert("There was a problem while trying to retrieve account names. Please contact support");
});