Events in yii.activeForm.js

Hi! Explain please. Why is events in yii.activeForm.js file triggering before method body? For examlpe i want to set custom handler on "afterValidateAttribute" event:




$(document).on('afterValidateAttribute', '#editor-form', function() {

    // Some code based on the result of the "updateInput" method

});



but in yii.activeForm.js




var updateInput = function ($form, attribute, messages) {

    var data = $form.data('yiiActiveForm'),

        input = findInput($form, attribute),

        hasError = false;


    if (!$.isArray(messages[attribute.id])) {

        messages[attribute.id] = [];

    }

    $form.trigger(events.afterValidateAttribute, [attribute, messages[attribute.id]]);


    // and here is starts main method body



Why is that? Thank.