How to use each2 jquery plugin on dynamically generated content?

Viewed 174

Is it possible to use each2 on html that is appended to the DOM, as a result of an AJAX call? The plugin itself is included at the top of the page, on page load.

I have some code like this:

$(".className").each2(function(){}));

where the .className divs are appended to the page via AJAX call. And I get this error:

Uncaught TypeError: $(".className")(...).each2 is not a function

Edit: link to each2 plugin https://raw.githubusercontent.com/cowboy/jquery-misc/master/jquery.ba-each2.js

This is how I am using it. It all works fine, except on dynamically added content. I'm aware that each2 can be replaced by other types of loops, is there a way to fix it without doing so?

   jQuery("some selector here").each2(function (i, element) {

   });
1 Answers
Related