Just wondering if this is something wrong that I am doing, intended mechanics or a bug.
See dojo: https://dojo.telerik.com/EfAQemOn
If you change the state of the "switch" it does not register that the underlying value has been changed and maintains the previous recorded value. If you interact with the view model via the checkbox it is recording the change state.
Is this something that is easy to fix without having to check the state value via the onchange event which currently seems to be the way you are testing for the change state value?
just incase I have copied the dojo code here for you as well.
<!DOCTYPE html>
<html>
<head>
<base href="https://demos.telerik.com/kendo-ui/switch/mvvm">
<style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }</style>
<title></title>
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2019.1.115/styles/kendo.material-v2.min.css" />
<script src="https://kendo.cdn.telerik.com/2019.1.115/js/jquery.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2019.1.115/js/kendo.all.min.js"></script>
<link rel="stylesheet" href="../content/shared/styles/examples-offline.css">
<script src="../content/shared/js/console.js"></script>
</head>
<body>
<div id="example">
<div class="demo-section">
<input data-role="switch"
data-bind="enabled: isEnabled, visible: isVisible, checked: isChecked, events: { change: onChange }" />
</div>
<input type="checkbox" data-bind="checked: isChecked, events: { change: onChange }"/> Change switch state
<div class="box">
<h4>Console log</h4>
<div class="console"></div>
</div>
</div>
<style>
.demo-section {
text-align: center;
}
</style>
<script>
var viewModel = kendo.observable({
isChecked: true,
isEnabled: true,
isVisible: true,
onChange: function (e) {
kendoConsole.log("event :: change (" + (e.checked ? "checked" : "unchecked") + ") \r\n calling Directly::" + viewModel.isChecked +"\r\nCalling Via Get Method:: " + viewModel.get('isChecked'));
}
});
kendo.bind($("#example"), viewModel);
</script>
</body>
</html>