KendoUI Multiselect取消选择事件未在jQuery中正确绑定

时间:2019-01-16 05:01:07

标签: kendo-ui

我尝试使用jquery将'deselect'事件绑定到KendoUI多选控件。但是似乎没有触发:这是代码:

$(document).ready(function () {
    function multiselect_deselect(e) {
        debugger;
        if (e.item.context.localName == 'li') {
            e.preventDefault();
        }
    }   
    var multiselectCtrl = $("#enterFeedbackForm_" + '@ContextId' + " #FeedbackCategoryList_" + '@ContextId').data("kendoMultiSelect");
    multiselectCtrl.bind("deselect", multiselect_deselect);
});

调试器点未命中。我们正在使用Kendo UI Kendo UI v2015.2.703

1 个答案:

答案 0 :(得分:0)

我认为kendo-ui已经为此具有绑定属性。如果您看一下event documentation,它向您展示了如何在kendo ui multiselect初始化时绑定事件:

$(document).ready(function() {

    function onDeselect(e) {
        debugger;
        if (e.item.context.localName == 'li') {
            e.preventDefault();
        }
    };

    var data = [
        { text: "Africa", value:"1" },
        { text: "Europe", value:"2" },
        { text: "Asia", value:"3" },
        { text: "North America", value:"4" },
        { text: "South America", value:"5" },
        { text: "Antarctica", value:"6" },
        { text: "Australia", value:"7" }
    ];

    $("#select").kendoMultiSelect({
        dataTextField: "text",
        dataValueField: "value",
        dataSource: data,
        deselect: onDeselect,
    });
});