How to catch the jQuery.event.trigger()?

javascript, jquery

Solution

I suppose you're asking about that custom event (at least it made no sense for me attempting to catch the `trigger`): it's done with .bind:

$('some_selector').bind('test', function() { 
  console.log('Test was caught'); }
);

UPDATE: Actually no, you don't need a selector - just an object to be a 'host' of event. You might use something like this:

// taken from the comments at the Doc page
var o = {length: 3};
$(o).bind( 'custom', function(){ console.log('hi') } );
$(o).trigger('custom');

// Output
hi
hi
hi

Problem

i want to build a custom event with jQuery that is not set to a DOM element. It says in the jQuery description, that: ``` jQuery.event.trigger('test'); ``` is to trigger an Custom Event. But how i can catch it ?? thx in advance

Original source