how to use live and trigger together?

jquery

Solution

You could trigger it like this:

<div id="test">CLICK</div>​
$('#test').live('click', function() {
    window.alert("works");            
});

$(document).trigger({ 
    type:   'click',
    target: $('#test')[0]
});

​ Basically, live handlers bind to the document element, so that's where you need to send the event

Problem

I am loading some content via Ajax. After the load completes I want to trigger a `click` event on an anchor element. But this doesn't seem to work. How can I use `trigger` and `live` together?

Original source