Related Posts

Archive

Manually Firing events in Prototype.js

December 3rd, 2008

By Prototype.js, I mean version 1.6.x .

By manually firing events, I mean the following:

In plain old JavaScript, one could fire off object listeners with somthing like getElementById(’who_me’).OnClick(). Prototype obviously would have a better way of doing this — except it doesn’t. Event.fire almost fits the bill — until you read it is only for custom events.

protolicious’s Event.simulate does fit this bill. For example, If I wanted to trigger my display-switch function after clearing a few selects…

$$('#i_has_childern select').invoke('clear').invoke('simulate','change');

… thus firing the events I would have expected Element.Form.clear to trigger on its own.

Note to self: Tarball from GitHub (as Win32 Git isn’t all it could be):

Posted in JavaScript |

Comments are closed.

Previous post: Change file character encoding

Next Post: