custom event not seeming to be handled by on()
Hi all,
I am trying to throw a custom event and have it handled using .on(). Here is the gist of what I have:
- jQuery( document).ready( function(){
- jQuery( 'a' ).click( function( ev ){
- ev.preventDefault():
- ...
- console.log( 'triggering controllerChange event ...' );
- jQuery( document ).trigger( 'controllerChange' );
- });
-
- jQuery( documunt ).on( 'controllerChange', function( ev ){
- console.log( 'controllerChange being handled.');
- ...
- });
- });
When clicking a link on the page, I get the 'triggering controllerChange event ...') message in my console, but the operations in the handler do not take place and the console does not log the 'controllerChange being handled' message. My understanding of trigger() and on() is that this should work. Any ideas on what I am doing wrong?