views:

28

answers:

2

How to get a mouse position inside open function of jQuery Dialog?

A: 

tried google?

$('#mydialog').mousemove(function(e){
    var offset = $('#mydialog').offset()

    // e.pageX - offset.left
    // e.pageY - offset.top
}); 

Edit re: comment

afaik the mouse coordinates are only available on mousemove. You will need to use something like $('html').mousemove to constantly capture the coords to global vars, then do something with them on open

Andrew Bullock
I said, "inside open function"
Mayur
He Said "inside open function"!
RobertPitt
A: 
$("#dialog").dialog({
   open: function(event, ui)
   {
        var offset = $('#mydialog').offset();
        var P_LX = e.pageX - offset.left
        var P_TY = e.pageY - offset.top
   }
});
RobertPitt
ahh the magical `e` variable! how did i forget?! If youre going to plagiarise, at least make some attempt to disguise it. seriously.
Andrew Bullock
plagiarise... I was not plagiarising your code, yes i used, merely to save time writing it... there's no other way to write that code, apart from variable renaming. get a grip.
RobertPitt