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
2010-08-23 09:33:36
I said, "inside open function"
Mayur
2010-08-23 09:58:45
He Said "inside open function"!
RobertPitt
2010-08-23 22:17:17
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
2010-08-23 10:16:15
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
2010-08-23 19:54:01
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
2010-08-23 22:16:57