0

I'm working on a tooltip plugin and have created my own mouseEnter, mouseMove and mouseOut functions that way the mouseMove function only triggers if I don't specify where the tooltip is going to be position in relation to the element.

However, I'm having some issues getting the e.PageY and e.pageX values because it says that e is undefined. I was told that if I don't pass in e to the function then it gets created automatically. I've never heard of this before so I'm not quite sure if I'm doing this right or wrong. Here's the mouseMove function that I've created.

function _mouseMove(e)
{
    tooltip.text(title);

    var position = $(this).data('position');
    var top = e.pageY + 75;
    var left = e.pageX + 10;

    tooltip.css('top', top).css('left', left).show();
}

Is there something else that I'm supposed to do in order to get these values since I'm not using $(this).mousemove()?

Edit: Here's how I'm calling the mousemove event:

if (options.position == "" || options.position == undefined || options.follow == true)
{
    _mouseMove();
}
Pallas
  • 1,499
  • 5
  • 25
  • 57
  • 2
    How are you calling your `_mouseMove` function to provide the event to it? – Rory McCrossan Aug 10 '14 at 17:24
  • "I was told that if I don't pass in e to the function then it gets created automatically." I do not believe this is the case in like firefox for example. In chrome I believe you can call event. or e. something and it will work though. – Scott Mitchell Aug 10 '14 at 17:32
  • @RoryMcCrossan see my edits above for how I'm calling the function – Pallas Aug 10 '14 at 17:48
  • You are not providing the event to the function. You need to pass it as a parameter. There is nothing provided to a function by default, so whoever told you that was wrong. – Rory McCrossan Aug 10 '14 at 17:51
  • What would I need to provide since I'm not using the on event? – Pallas Aug 10 '14 at 17:59
  • Unfortunately, there is no way of getting "e" without using an event listener like `.mousemove()` or `.on()`: http://stackoverflow.com/questions/2601097/how-to-get-the-mouse-position-without-events-without-moving-the-mouse – stekhn Aug 10 '14 at 18:29

0 Answers0