I am using kendoUI auto complete. To display each record in the box format with “x” mark I have implemented like
$("#roleAuto").kendoAutoComplete({
dataSource: roledata,
filter: "startswith",
placeholder: "Select Role...",
select: function (e, ui) {
alert("hi");
$(".roleSelection:checked").each(function () {
var role = $(this).attr("data-name"),
var span = $("<span>").text(role),
a = $("<a>").addClass("remove").attr({
title: "Remove " + role
}).text("x").appendTo(span);
alert(role);
span.insertBefore("#roleAuto");
$("#Roles").click(function () {
$("#roleAuto").focus();
});
$(".remove", document.getElementById("Roles")).live("click", function () {
$(this).parent().remove();
if ($("#Roles span").length === 0) {
$("#roleAuto").css("top", 0);
}
});
});
I am able to display each record in the box with “x” symbol. If I click on the “x” mark I am able to remove the record, I want that removed item ID value. How can I get this?
There is a method for the autocomplete (and many of the other data-bound widgets):
kendo.ui.widget.dataItem(index);
And a method on the event called:
event.item.index();
Documentation for the AutoComplete-Methods: AutoComplete Documentation
So, as your first line in the select function, you could write:
Your live-method for the click-event would then look like the following: