Reputation: 8284
How could I get the offset(); of my kendo window while it is being dragged... For instance, in jQuery UI, the below works:
$('#easterEgg').draggable(
{
drag: function(){
var offset = $(this).offset();
var xPos = offset.left;
var yPos = offset.top;
$('#posX').text('x: ' + xPos);
$('#posY').text('y: ' + yPos);
}
});
But when I try to incorporate the same, with kendo ui, I get nothing: Have tried a few variants of below, no errors, just no output. How can I do the same with kendo ui?
$("#easterEgg").kendoWindow({
draggable: true,
drag: function(){
var offset = $(this).offset();
var xPos = offset.left;
var yPos = offset.top;
$('#posX').text('x: ' + xPos);
$('#posY').text('y: ' + yPos);
}
});
Upvotes: 0
Views: 312
Reputation: 21465
There is a few mistakes in your code.
First of all, there is no drag
event, please check the docs. You have to use dragstart
or dragend
for that.
Second problem is that javascript frameworks differ from each other in their functionalities. Because this
in jQuery UI is the modal's element doesn't means that its the same for all other frameworks. On Kendo UI this
keyword in most cases is the widget's instance, which makes much more sense than refering only to the target element. The widget's instance has a property called element
which is the target element where the widget is created over.
Given that, your code should be:
dragstart: function() { // or dragend
let offset = $(this.element).offset();
}
Upvotes: 1