jQuery delegate and on are good for this. Please note: if you are using older versions of jQuery, you can use delegate , but if you are using the latest version (1.7+), you need to use on .
With them, you must call the method using an already loaded element and use the parameter to specify the element that triggers the event. To make this as efficient as possible, this element must be the closest parent to the dynamically created element.
For example, if you click on the anchor tag, you put the div with the identifier "target" in the container that was already loaded before calling on , with the identifier "container", your on call should be.
$('#container').on('click', '#target', function(){ $(this).pluginCall(); });
You cannot just call on in the #target div, because this element is not yet loaded.
Another solution is to place the built-in $(document).ready() function in the dynamically generated content that your plugin calls. You do not need on or delegate in this case, but this will only work for loadable elements. In the first example, any #target instance that is created from any ajax call will be a click handler.
anson source share