It seems that you are facing a few problems, but all the more important it would be to know when an element is rendered in the DOM so that you can manipulate its collection of events.
Once an element is available, simply unbind the plugin handlers, bind them and reassign the plugin, knowing that you can access the jQuery event collection: $ ._ data (domEl, 'events');
Here is an example:
var $div = $('<div>').click(function () { console.log('plugin'); return false; }), clickListener = jQuery._data($div[0], 'events').click[0];
If you don't want to unleash, I believe that you can also use the DOM level 0 event model and follow these steps:
element.onclick = yourHandler;
To know, to know when an element is available, is much more problematic if the plug-in renders this element asynchronously and does not provide a way to know when the process will be completed.
If you want to support older browsers, you will have no choice but to override the plugin code (provided that the appropriate methods are public) or poll the DOM with setInterval until the item you were looking for is part of the DOM, and then you can do what we talked about above.
If you use modern browsers, you can use the MutationObserver object to listen for DOM changes.
plalx source share