Here is what I did.
This is a combination of the Juan Mendes solution and using the prototype library method
Initially, there was a function that ran this code:
myObject.adjustSection(section) { jQuery(document).trigger('section:' + section); }
So, I expanded the function with the wrap
prototype since my project used the prototype as well as jQuery.
// My custom function wrapper // extend adjustSection to include new event trigger myObject.prototype.adjustSection = myObject.prototype.adjustSection.wrap( function(parentFunction, section) { // call original function parentFunction(section); // fire event w/section info jQuery(document).trigger({ type: 'adjustSection', section: section }); } );
Then it fires the source file, but also fires my custom event, which includes the section information.
Now I can do this to watch this event and get the section type:
jQuery(document).on('adjustSection', function(event) { event.section;
Of course, this means that I have to use both prototype and jquery in the same area, which is not the best in the world. But it worked.
source share