Say I have some actions binded to a link ( with .click or .live), and I want to do the same thing later, but I don't want duplicated code. Which is the correct way and why?
This:
$('#link').click(function(){
//do stuff
});
//called later
$('#link').trigger('click');
OR:
$('#link').click(function(){
do_stuff();
});
//called later
do_stuff();
//defined here
function do_stuff(){
//do stuff
}