Custom events and event pooling in jQuery - What's the point?
<p>I've been reading about custom events in jQuery and why they should be used but I'm still clearly missing the point. There is a very good article I read <a href="http://www.michaelhamrah.com/blog/index.php/2008/12/event-pooling-with-jquery-using-bind-and-trigger-managing-complex-javascript/" rel="nofollow">here</a> that has the following code example;</p>

<pre><code>function UpdateOutput() {
    var name = $('#txtName').val();
    var address = $('#txtAddress').val();
    var city = $('#txtCity').val();

    $('#output').html(name + ' ' + address + ' ' + city);
}

$(document).bind('NAME_CHANGE ADDRESS_CHANGE CITY_CHANGE', function() {
    UpdateOutput();
});

$('#txtAddress').keyup(function() {
    $(document).trigger('ADDRESS_CHANGE');
});
$('#txtCity').keyup(function() {
    $(document).trigger('CITY_CHANGE');
});
</code></pre>

<p>Can someone tell me why I just don't call the UpdateOutput() function directly? It would still work exactly the same way, i.e.</p>

<pre><code>$('#txtAddress').keyup(function() {
    UpdateOutput()
});
$('#txtCity').keyup(function() {
    UpdateOutput()
});
</code></pre>

<p>Many thanks</p>
