![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
It's perhaps something elementary. I tried to do suff as follows. document.getElementById ('Button1').on ( 'click', funcion () {}); For some reason, the method isn't there. According to FireBug i get this. |
|
document.getElementById ('Button1').on (gives nothing - no such method) |
|
Ext.get ('Button1').on (gives function ()) |
#3
| |||
| |||
|
|
It's perhaps something elementary. I tried to do suff as follows. document.getElementById ('Button1').on ( 'click', funcion () {}); For some reason, the method isn't there. According to FireBug i get this. document.getElementById ('Button1').on (gives nothing - no such method) while Ext.get ('Button1').on (gives function ()) What do i miss? |
#4
| |||
| |||
|
|
With the DOM API events are set either directly: document.getElementById('Button1').onclick = function() { ... } or with addEventListener: document.getElementById('Button1').addEventListene r("click", function() { ... }, true); |
|
Which IE however doesn't support. You need to use attachEvent for IE. |
#5
| |||
| |||
|
|
It's perhaps something elementary. I tried to do suff as follows. document.getElementById ('Button1').on ( 'click', funcion () {}); For some reason, the method isn't there. According to FireBug i get this. Because there isn't such a method. document.getElementById ('Button1').on (gives nothing - no such method) Right. document.getElementById returns a DOM reference, and the DOM API doesn't have a method "on". Ext.get ('Button1').on (gives function ()) Ext.get is a method of a 3rd party libary (I'm guessing "Ext" :-) that returns something else than a DOM reference which does have an "on" method. I'd suggest as a JavaScript beginner, you should avoid using 3rd party libraries until you know what you're doing, or at least read their documentation. With the DOM API events are set either directly: document.getElementById('Button1').onclick = function() { ... } or with addEventListener: document.getElementById('Button1').addEventListene r("click", function() { ... }, true); Which IE however doesn't support. You need to use attachEvent for IE. More details at: http://developer.mozilla.org/en/docs...dEventListener |
#6
| |||
| |||
|
|
On May 23, 11:08 am, K Viltersten wrote: document.getElementById ('Button1').on (gives nothing - no such method) while Ext.get ('Button1').on (gives function ()) What do i miss? That - document.getElementById - returns an element from the DOM and - Ext.get -(whatever that is) either returns a different sort of object or returns a DOM element that has been subject to (direct or indirect) augmentation prior to being returned. |
#7
| |||
| |||
|
|
document.getElementById('Button1').addEventListene r("click", Reference Worms[tm] are error-prone, and should therefore be avoided. PointedEars |
![]() |
| Thread Tools | |
| Display Modes | |
| |