$("#shout_field").live('keydown', function (event) {
if (event.keyCode === $.ui.keyCode.TAB && $(this).data("autocomplete").menu.active) {
event.preventDefault();
}
}).autocomplete({
minLength: 0,
source: function (request, response) {
var term = request.term,
results = [];
if (term.indexOf("@") >= 0) {
term = extractLast(request.term);
if (term.length >= 2) {
$.ajax({
type: "POST",
url: "/data/people.asp",
dataType: "json",
data: {
term: term
},
error: function (xhr, textStatus, errorThrown) {
alert('Error: ' + xhr.responseText);
},
success: function (data) {
response($.map(data, function (c) {
return {
id: c.id,
label: '<b>' + c.img + '</b>' + c.label,
value: c.value
}
}));
}
});
} else {
results = ['Type someones name to tag them in the status...'];
}
}
response(results);
},
focus: function() {
// prevent value inserted on focus
return false;
},
select: function (event, ui) {
var terms = split(this.value);
// remove the current input
terms.pop();
// add the selected item
terms.push(ui.item.value);
// add placeholder to get the comma-and-space at the end
terms.push("");
this.value = terms.join("");
$('body').data('tagged', this.value)
var tagged_users = $("#tagged_users").val();
$("#tagged_users").val(tagged_users + ui.item.id + ',')
return false;
}
});
私は通常、それを行うが、私は混乱していますリモート呼び出しからのオートコンプリートを持つことができます... :(このjqueryオートコンプリートスクリプトに画像を含めるにはどうすればよいですか?私が興味を持って
ビットはc.img
が<b>
タグである部分であり、それはにISN HTMLのように「トンレンダリング...
をもしかして?私は自分のコードを理解しています。 –
'c.img'に関する質問があります。プロパティには何が含まれていますか?イメージへのURL? –
それは単に 'imagename.jpg'と同じです。 –