Epic explanation. More of these should be said. :o
On 30 nov, 06:03, piotr_cz <pkoniec...@hotmail.com> wrote: > This is so helpful that it should be in documentation. > (Google doesn't effectively show results for it's own google groups) > > On Nov 10, 8:59 pm, Arian Stolwijk <stolwijk.ar...@gmail.com> wrote: > > > > > > > > > There is a object defined and used by MooTools, called Element.NativeEvents. > > > This is an object with all known DOM event types, like click, mouseover, > > load, etc. > > Each event type has a value, possible values are 0 (undefined, null), 1, > > and 2. > > > By default it is undefined. In this case you can add events, but you should > > manually fire them. For example: element.addEvent('pizza', fn); > > element.fireEvent('pizza', 'yum!'); The event is *not* actually added to > > the DOM, but is only registered in a JS object. > > > The second case is if the value is 1. This time the object is attached to > > the DOM. Usually by element.addEventListener, or element.attacheEvent in > > oldIE. You can still use element.fireEvent('load') to manually fire events. > > > The final case is if the value is 2. This is the same as case 1. The only > > difference is that the event object, containing interesting data, is > > wrapped and normalized by event wrapper (DOMEvent). This is the most used > > variant, for mouseevents (like click) and keyboard events. > > > The reason to differentiate between 1 and 2 is that 1 is usually used for > > events that don't have interesting data, like onload, onscroll, onresize. > > Those last two fire an awful lot as well. > > > The problem however, is that the event type has to be registered in the > > object, otherwise it will handle the event as case 0. This can be done > > with, for example: > > > Element.NativeEvents.popstate = 2; > > // Now element.addEvent('popstate', fn); will work everywhere > > > More info can be found at pages 301-302 of Pro JavaScript with MooTools by > > Keeto, or in the source code! > > > On Thu, Nov 10, 2011 at 8:22 PM, zipz <anders.bergv...@gmail.com> wrote: > > > Can someone explain how I can get the popstate event to be fired, with > > > ordinary mootools addEvent, when I use back/forward button in the > > > browser. > > > > This code does not work > > > window.addEvent('popstate', function(event) { > > > console.dir(event); > > > }); > > > > This code does work > > > window.onpopstate = function(stackstate) { > > > console.dir(stackstate); > > > }; > > > > I don't think it's possible to add this in jsfiddle.