rborda
asked on
Dropdownlist not working properly
Thank you in advance for any feedback.
I have the following code in this url: http://dojo.telerik.com/@rbordavol/UTIfu
$('#kdlResponsibleOffice') .data('ken doDropDown List') this part of the code returns Unable to get property 'value' of undefined or null reference , so I can not do a bind or a initial assigment:
========================== ========== ========== ========== ========== ========== ========== ========== ========== =====
I have the following code in this url: http://dojo.telerik.com/@rbordavol/UTIfu
$('#kdlResponsibleOffice')
$('#kdlResponsibleOffice').data('kendoDropDownList') .value("Off2");
==========================
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled</title>
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2015.3.1111/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2015.3.1111/styles/kendo.rtl.min.css">
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2015.3.1111/styles/kendo.default.min.css">
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2015.3.1111/styles/kendo.mobile.all.min.css">
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2015.3.1111/js/angular.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2015.3.1111/js/jszip.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2015.3.1111/js/kendo.all.min.js"></script></head>
<body>
<input id="kdlResponsibleOffice" data-role="dropdownlist" data-text-field="FullName" data-value-field="ShortName" data-bind="source:offices, value: responsibleOffice" style="width:550px" />
<script>
//constructor, members initialization
var sysInfoId = 13001;
var InventorySystemInfoEditor = function (sysInfoId) {
this.sysInfoId = sysInfoId;
this.sysInfo = null;
this.lnk = null;
};
InventorySystemInfoEditor.prototype = function(){
var sie = this;
load = function() {
debugger;
loadDDL.call(sie);
}
,
loadDDL = function() {
$(function() {
var offices = [
{ FullName: "Office 1", ShortName: "Off1" },
{ FullName: "Office 2", ShortName: "Off2" },
{ FullName: "Office 3", ShortName: "Off3" }
];
var vmOffices = kendo.observable({offices: offices, responsibleOffice: offices[2]});
kendo.bind($('#kdlResponsibleOffice'), vmOffices);
$('#kdlResponsibleOffice').data('kendoDropDownList').bind('change', function () {
alert(1);
});
$('#kdlResponsibleOffice').data('kendoDropDownList').value("Off2");
});
}
;
return {
load: load
};
}();
inventorySysInfoEditor.load();
</script>
</body>
</html>
ASKER
micropc1: that did not solve the problem, thanks for the suggestion.
I don't understand what you are trying to do
This line
In your code #kdlResponsibleOffice is an input element but it has no custom data element kendoDropDownList.
Then assuming the custom data does exist then this does not make sense
what is .value() doing - did you mean .val("Off2") - and binding it to the the data() call which returns a string is not going to work.
Maybe explain what you are trying to do and we can take it from there.
This line
$('#kdlResponsibleOffice').data('kendoDropDownList')
implies you have an element ID=kdlResponsibleOffice that has a custom data element data-kendoDropDownList.In your code #kdlResponsibleOffice is an input element but it has no custom data element kendoDropDownList.
Then assuming the custom data does exist then this does not make sense
$('#kdlResponsibleOffice').data('kendoDropDownList').value("Off2");
what is .value() doing - did you mean .val("Off2") - and binding it to the the data() call which returns a string is not going to work.
Maybe explain what you are trying to do and we can take it from there.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This resolved the issue to the problem I was looking for.
inventorySysInfoEditor.loa
...inside a $.ready() method to make sure it executes after the DOM is fully loaded.
https://api.jquery.com/rea
Open in new window
window.onload would also work.