Search code examples
asp.net-corekendo-uiswitch-statementtelerik

Possible to pass a data value from a kendoSwitch


Is it possible to pass a data value from a kendoSwitch?

Simple dojo here: https://dojo.telerik.com/eCUVitEC/2

Code as follows:

<input type="checkbox" id="theSwitch" data-id="MyId" />
<script>
    $(function () {
        $("#theSwitch").kendoSwitch({
            change: function (e) {
                alert("checked: " + e.checked);
            }
        });
    });
</script>

This works but what I really want is to pass the data-id, not the checked value. I have tried a number of ways but can't seem to find the right syntax.

Thanks.

-Dan


Solution

  • Sure. On change event find attribute in that element:

    this.element.attr("data-id");
    

    Example: Get element attribute