Search code examples
javascriptjquerykendo-uikendo-window

How to open a Kendo window at mouse pointer


Is there a way to open a Kendo UI Window at the mouse pointer?

I can see in the Telerik demo for the Window API, that I can open it on center of the page, but I want to open it at the mouse pointer.


Solution

  • First, keep the current mouse position stored somewhere:

    var currentMousePos = { x: -1, y: -1 };
    $(document).mousemove(function(event) {
        currentMousePos.x = event.pageX;
        currentMousePos.y = event.pageY;
    });
    

    Then, when opening your Kendo Window:

    $("#window").closest(".k-window").css({
        top: currentMousePos.y,
        left: currentMousePos.x
    });