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 = $'yiiActiveForm'),

        input = findInput($form, attribute),

        hasError = false;

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

        messages[] = [];


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

    // and here is starts main method body

Why is that? Thank.