If you can get by with the standard events then this is very simple. You bind an event handler to the div in the widget (assume the div has id="widget"
) thus:
$('#widget").bind('click', function(e){
// your code here runs when widget div receives the click event.
// e is the W3-standard DOM event, in case you need it, but
// you're free to ignore it
});
then you can trigger that from elsewhere with $('#widget").click()
. It would be neat to define custom events to do this but that's a bit more advanced. Once you have the basics working you can google "jquery custom events".