I am currently creating an application that receives data from a server and then dynamically creates dumped items. Now I have a code that allows the animation of opening and closing folding elements throughout the application:
$('[data-role="collapsible"]').bind('expand', function () { $(this).children().slideDown(500); }).bind('collapse', function () { $(this).children().next().slideUp(500); });
Now this code does not work with dynamically created dumped elements. So I tried to do the following:
$(document).on('pagechange','#resultssearch', function() { $('[data-role="collapsible"]').bind('expand', function () { $(this).children().slideDown(500); }).bind('collapse', function () { $(this).children().next().slideUp(500); }); });
So, on the page where the dynamic folding elements are added, I tried to add the above page event. But some of them also do not work. How will I be dynamically generated for animation?
As shown in the suggested answers, the code that works is defined as:
$(document).on('expand', '[data-role="collapsible"]', function () { $(this).children().slideDown(500); }).on('collapse', '[data-role="collapsible"]', function () { $(this).children().next().slideUp(500); });
Whatever it is 100%. Events of childhood collapses ultimately affect parental collapses, this can be seen here . Is there a way to stop children from doing routine work?
source share