I having problems when applying the toggle
to my divs
. These divs are created after an ajax
call which fetches data and creates the divs. After this, I'm applying the toggle for these divs by calling activateToggles()
. So far, everything works fine.
However, if I click 'load more
' which will fetch the next 10 rows, the ajax will append more divs on the page, the new divs will have the correct behavior but the previous ones will toggle twice, meaning they will expand and contract.
If I load more, then the initial ones will toggle x3, next ones x2, and new ones would be ok.
I believe the problem is when the activateToggles()
it shouldn't assign a toggle
to the divs that already have it. But how do I check this?
function activateToggles() {
jQuery(function () {
jQuery(".medical-details").hide();
jQuery(".toggle").click(function () {
var that = jQuery(this);
that.next().toggle("fast", function () {
});
});
});
}