Reputation: 1157
After some reading from this tutorial, I have the following partly working code:
$(document).bind ("found_match", function(e){
$('#status2').html(e.pageX +', '+ e.pageY);
});
When the event: "found_match happens", it should show the mouse coordinates in the div: "status2", but it doesn't. Obviously because I am missing the .mousover(). But where to put this in my code to make it work so that it wil show the mouse coordinates the moment this event happened?
Many thanks
Upvotes: 1
Views: 220
Reputation: 146350
Try this:
$('#someID').mousemove(function(event){
$(document).trigger('found_match', event);
});
Here is a fiddle example: http://jsfiddle.net/maniator/M3FwY/
(I had to change the parameters of your custom function a bit)
Upvotes: 1
Reputation: 359986
found_match
is a custom event. You, the programmer need to trigger
that event at some point.
$('#foo').mousemove(function (e)
{
if (someCondition) // probably involving e.pageX and e.pageY
{
$(document).trigger('found_match');
}
});
Upvotes: 1