am using tag-it plugin in jQuery and it works fine. But i can't set the autocomplete function.
Here is my script:
<script type="text/javascript">
$(document).ready(function () {
$('#tags').tagit({
tagSource: function (request, response) {
$.ajax({
type: "POST",
url: "Main/TagHelper",
data: request,
dataType: 'json',
contentType: "application/json",
success: function (choices) {
showChoices(this._subtractArray(choices, this.assignedTags()));
}
})
}
});
});</script>...and code-behind method:
public ActionResult TagHelper(string term)
{
var data = db.Tags
.Where(t => t.Name.StartsWith(term))
.Select(t => t.Name)
.Take(10);
return Json(data, JsonRequestBehavior.AllowGet);
}I was finding where is the problem. But all i know is, that method $.ajax() is called. But i do not understand jQuery, so i do not know why it does not work.
