Search code examples
kendo-uikendo-window

Get Kendo Window in the drag event


I'm binding to the drag event of my windows.

$("#@Model.Name").data("kendoWindow").dragging._draggable.bind("drag", function (e) {    
var wnd = $("#@Model.Name").data("kendoWindow");

Now, I'd like to write one function and bind all of the windows to that function, so I cannot hard-code the window's id. How can I get the sender window in that function?

I've tried the followings:

$(e.target).closest('.k-window').data('kendoWindow')
$(e.currentTarget).closest('.k-window').data('kendoWindow')
$(e.sender).closest('.k-window').data('kendoWindow')

all of them return null.


Solution

  • You want .k-window-content

    $('.k-window-content').each(function(){
        $(this).data("kendoWindow")...
    });
    

    Edit, OP wanted to use the dragging._draggable.bind method:

    $("#id").data("kendoWindow").dragging._draggable.bind("drag", function (e) {
        e.currentTarget.parent().find(".k-window-content").data("kendoWindow")...
    });