I have a kendo combobox with an OnSelect method defined on the page, but would like to move it to the jQuery ready function. How do I do that?
Right now, the code looks like this:
I want to place it within :
The ready function is in an external JavaScript file that gets loaded at the bottom of the page.
Right now, the code looks like this:
<%= Html.Kendo().ComboBox()
.Name("contactsAc")
.Filter("startswith")
.Placeholder("Select a Contact")
.MinLength(3)
.HtmlAttributes(new { style = "width:250px;" })
.DataSource(source => source.Read(read => read.Action("ContactSelect", "TrainingSchedule")
.Data("onAdditionalData"))
.ServerFiltering(true))
.DataTextField("Name")
.DataValueField("Id")
.AutoBind(false)
.Events(e => e.Select("onSelect"))
%>
<
script
language
=
"javascript"
type
=
"text/javascript"
>
function onSelect(e) {
var dataItem = this.dataItem(e.item.index());
var contact = new Object();
contact.ContactId = dataItem.Id;
contact.ContactName = dataItem.Name;
vm.assignedContacts.push(contact);
kendo.bind($(document.body), vm);
}
</
script
>
$(function () {
$("#startDate").kendoDatePicker();
$("#endDate").kendoDatePicker();
$("#detailForm").kendoWindow({
height: "450px",
title: "Training Schedule Detail",
visible: false,
width: "600px"
}).data("detailForm");
$grid.data = $("#grid").data("kendoGrid");
$("#detailForm").submit(function () {
if (validateData()) {
formSubmit();
}
return false;
});