Custom Event Handlers on $(document) do work:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>OnEventHandler</title>
<script src="Scripts/jquery-2.1.0.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$(document).on('click filterEvent', '.action_element', function () {
alert('You Clicked Me!');
});
$('#OrderFilter').change(function () {
$('#CustomerFilter').trigger('filterEvent');
});
$('#CustomerFilter').on('filterEvent', function () {
alert('CustomerFilter filterEvent');
});
});
</script>
</head>
<body>
<p>Some text.</p>
<p class="action_element">Click me!</p>
<select id="OrderFilter">
<option>By Order Id</option>
<option>By Order Total</option>
</select>
<p id="CustomerFilter" class="action_element">Just some Text...</p>
</body>
</html>
You can delegate a handler for a custom event using $(document).on('event', 'selector').
EDIT
So, that rules out anything fishy with custom events propagating up to the document level and being handled by a delegated event handler there.
Looking at the JQM filter and your question, are you asking: if they click in the input box or the input box changes, or the widget is right before it starts applying filtering to some data, then do function(){...}?
If the intent is to override the filtering process to get some data to filter on, before filtering is done, as the documentation puts it; from the database first (Google search comes to mind...) wouldn't it make sense that it applies to the widget at hand? If you had more than one widget in the app, would you want all of them to have the same DB call for data (say 4 google search input boxes on the same page?)
It would make sense that beforefilter event would have to be unique for each widget (think 3 text boxes, one for google, one for yahoo, one for bing). If so, How they accomplish this I don't know yet (but will try as I am interested in knowing...)
Also, there is a 250ms delay before the filter kicks in, so it waits to see if the user is done typing... With the change event being delegated as well, the handler would execute for it, and be done or on the way to being done 250ms later when the beforefilter event is fired... so the handler gets executed twice? Whether it does or does not, does it make sense?
I'm guessing, they have it so it can only have a beforefilter event handler per widget, by design as explained above. Also note in the documentation example, they are using the direct binding notation of .on() (no selector specified). Everything points to a binding to an element, rather than delegation.