Understanding prototype method calls
Posted
by Tristan
on Stack Overflow
See other posts from Stack Overflow
or by Tristan
Published on 2010-06-03T00:18:13Z
Indexed on
2010/06/03
0:24 UTC
Read the original article
Hit count: 633
JavaScript
In trying to call a method on the CodeMirror javascript code editor. I'm new to javascript and trying to understand how object oriented stuff works. I'm having problems calling what I believe are methods. For instance,
var editor = CodeMirror.fromTextArea('code', options);
editor.grabKeys(function(e) { alert("Key event");});
This gives the Uncaught TypeError: Cannot call method 'grabKeys' of undefined
. Looking at the editor
object reveals that grabKeys seems to be located at editor.__proto__.grabKeys
.
How should I be thinking about this?
© Stack Overflow or respective owner