views:

89

answers:

2

I have a DIV container that draws a list of bars (al container 'onmousemove' and 'onmouseout' events). When an item is hovered, it changes the images of the item, and back again when the mouse is moved away.

Now, I have a looped AJAX request that gets the new information for this DIV container and re-draws the innerHTML every 3 seconds, causing whatever item i have my mouse over to go back to its normal state (un-hovered).

Does anyone have any suggestions on how to fix this? Is there a method to force a mouse move? Any help would be greatly appreciated.

+1  A: 

Is this a good design to poll an AJAX request every 3 seconds?

Why don't you set a flag when mouse is over the item and when the response is fed to the div then check the flag and show the image change.

Edit:

Check

event.initMouseEvent

Intializes the value of a mouse event once it's been created (normally using document.createEvent method).

This might be useful.

rahul
Because the items that come back may change in order, so doing this will be pointless at the item would be hovered, but the mouse may still be in the same place.
williamtroup
A: 

What you are trying to accomplish is more efficiently executed using the hover pseudo-class of CSS instead of firing JavaScript.

The reason I'm using JavaScript is because when I Hover, I have to change more than 1 DIV element in the bar that I'm changing
williamtroup