OOUI/OOjs primer/id

Pustaka OOUI didasarkan pada model event yang disediakan oleh. Jika Anda tidak terbiasa dengan OOjs, Anda mungkin ingin meluangkan waktu sejenak untuk membiasakan diri dengan -nya, karena ini adalah alat yang nyaman dan kuat yang akan sering digunakan dalam contoh.

EventEmitter allows event handlers to be connected to an object, called when events occur, and disconnected when no longer needed. Events are tied to their context. For example, when a toggle button changes state, the event is not simply ‘change,’ but ‘change’ and the value of the toggle button’s state ( ‘on’ or ‘off’).

The most basic way to connect and disconnect an event handler is with the EventEmitter’s  and   methods. In the following example, the  method is used to connect an   event handler to a toggle button, which is defined in the example as well.

Often, the  and   methods are used to connect and disconnect multiple event handlers to objects. The following example illustrates these methods.

For more details about EventEmitter, please see OOjs/Events.