You have to bind event handler to 'this'
document.observe('mousemove', this.storeMousePosition.bind(this));
$('testDiv').observe('mouseover', this.checkAndTell.bind(this));
Seb
---
http://xilinus.comWeb Application Development, Consulting, Training
http://mapeed.com Markers fusion plugin for your online maps
On Jan 31, 2009, at 10:37 PM, Stefano Esposito wrote:
Hi all, can anyone tell me what's wrong with this piece of code
(minimal example):
=== CODE ===
html
head
script type=text/javascript src=js/prototype.js/script
script type=text/javascript
var testClass = Class.create({
initialize: function () {
document.observe('mousemove', this.storeMousePosition);
$('testDiv').observe('mouseover', this.checkAndTell);
},
storeMousePosition: function (event) {
this.mouseX = event.pointerX();
this.mouseY = event.pointerY();
},
checkAndTell: function () {
$('ansDiv').update('x: '+this.mouseX+'; y: '+this.mouseY);
}
});
document.observe('dom:loaded', function () {
new testClass();
});
/script
/head
body
div id=testDivThis is the mouseover div/div
div id=ansDiv/div
/body
/html
=== END CODE ===
It's not working in firefox 3.0.5 (gives x:undefined; y:undefined in
div#ansDiv).
The purpose is to store mouse coordinates in class
variables as the mouse move and tell what's their value when the
mouseover div#testDiv event happens.
Thanks for your help :)
Ciao,
Stefano
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Prototype script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---