0
我正在使用jquery自動完成的knockoutjs工作正常,除了自動完成結果顯示符號以及文本。jockery自動完成Knockoutjs顯示自動完成結果中的符號
ko.bindingHandlers.ko_mission_autocomplete = {
init: function (element, params) {
var options = params().split(' ');
var searchType = options[0];
$(element).bind("focus", function() {
$(element).change();
});
$(element).autocomplete({
source: function (request, response) {
var keyword = request.term;
//return result;
$.ajax({
type: "POST",
url: SolrUrl,
dataType: "json",
contentType: "application/json; charset=utf-8",
data: '{ "searchSource":' + searchSource + ', "searchTarget": "' + searchTarget + '", "keyword": "' + keyword + '" }',
success: function (data) {
//alert("ajax request called successfully");
var tempData = $.parseJSON(data.d);
response($.map(tempData, function (item) {
return {
label: item.Name,
value: item.Name,
id: item.ID
}
}));
},
error: function (xhr, errorType, exception) { //Triggered if an error communicating with server
var errorMessage = exception || xhr.statusText; //If exception null, then default to xhr.statusText
alert("There was an error : " + errorMessage);
},
complete: function (data) {
}
});
},
minLength: 3,
select: function (event, ui) {
$(this).change();
$(element).data("valueID", ui.item.id);
}
});
},
update: function (element, params) {
$(element).change();
}
};
當我確認它是否正確來JSON數據,然而,它示出了作爲符號。
請幫忙。
感謝
您確定這些符號不僅僅是CSS中定義的背景嗎? – sroes 2013-03-07 13:33:39
謝謝,我注意到背景圖像被應用。 – Prasad 2013-03-07 13:59:45