Ook ik ben bezig met een online editor. Hiervoor heb ik o.a. de volgende code:
Als ik deze code run, krijg ik als error:
JavaScript:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| Object.extend(textEditor.prototype, { createGutter : function() { var target = this.textarea; gutter = createNode('textarea', {'id' : target.name + '-gutter'}); target.onkeydown = function() { this.countLines(gutter); this.setLine(); } target.onkeyup = function() { this.countLines(gutter); this.setLine(); } }, setLine : function(el) { el.scrollTop = this.scrollTop; }, countLines : function(el) { var count = el.value.split('\n').length - 1; var lines = this.textarea.value.split('\n').length; if (lines != count) { var string = ''; for (var no = 1; no <= lines; no++) { string += no + '\n'; } el.innerHTML = string; } } }); |
Als ik deze code run, krijg ik als error:
Mijn vraag is: wat doe ik verkeerd? Voor zover is weet maak ik een valide functie-call...?this.countLines is not a function: line 6