This question is locked. New answers and comments are not allowed.
Hi there, I am trying to access Telerik MVC objects in MVC project from Javascript (event driven), following the documentation examples:
and then script:
problems are:
1. dropDownList variable in the script is ALWAYS null (or undefined) - hence I get exception and cannot access the control values etc...
2. the event OnListItemSelected() is being called at initialization (which might not be necessary but its fine) but it not being triggered thereafter (even if I comment the lines mentioned).
I have removed all other dependencies from the project (scripts like prototype that uses the $ sign) and therefore access to the element via $id should be clear. Still getting the same problem.
Anyone can help?
henric
aspx code:
<% Html.Telerik().DropDownList() .Name("dropdownlist") .ClientEvents(events => events .OnChange("OnListItemSelected()") ) .BindTo( (SelectList)ViewData["mylist"]) .SelectedIndex(0) .Render();%>and then script:
function OnListItemSelected(){ var dropDownList = $("#dropdownlist").data("tDropDownList"); var selectedValue = dropDownList.value(); ... continue process based on selected value ...}problems are:
1. dropDownList variable in the script is ALWAYS null (or undefined) - hence I get exception and cannot access the control values etc...
2. the event OnListItemSelected() is being called at initialization (which might not be necessary but its fine) but it not being triggered thereafter (even if I comment the lines mentioned).
I have removed all other dependencies from the project (scripts like prototype that uses the $ sign) and therefore access to the element via $id should be clear. Still getting the same problem.
Anyone can help?
henric