I have an interactive form system that has different modules, where the forms for each module is contained inside a different div element. When i change from one module to another, I often do this:
$('#module_1').hide();
$('#module_2').fadeIn();
I like this, but now, after developing this system for some time, I have some functions (like re-initialize a jqgrid) that I want to happen every time a fadeIn occurs. I set up this up like this:
$('#module_2').bind('fadeIn',function(){
initialize_jqgrid();
});
Is there a way I can make this work for all instances of $('#module_2').fadeIn(); without having to go to every instance and replace it with this?
$('#module_2').fadeIn().trigger('fadeIn');
The motivation behind this is just to have cleaner code, $('#module_2').fadeIn().trigger('fadeIn'); is a little redundant.
Thanks a lot!
Sure,
Demo
http://jsfiddle.net/gEVsX/2/
Update for comment