Module-documentation

version 1.0.0
module: itsa-event
maintanance: Marco Asbreuk
home
all modules

Class listening

Listening for events can be done by Event.after, but also by .after on an object or Class-instance. This example demonstrates the latter. You can add this functionality on the instance, by merging Event.Listener.

Click on the buttonto save profile.

Code-example:

<script src="itsabuild-min.js"></script>
<script>
    // create Class "Members" and merge ITSA.Event.Listener to the prototype:
    var Members = ITSA.Classes.createClass(null, ITSA.Event.Listener),
        myMembers = new Members();
    myMembers.after('PersonalProfile:save', function(e) {
        alert('personal profile is saved');
    });

    ITSA.Event.after(
        'tap',
        function() {
            ITSA.Event.emit('PersonalProfile:save');
        },
        '#buttongo'
    );
</script>
API Docs