I have a few .filter-options-title elements that are loaded via ajax with below jquery. Once added to the DOM i use an each function to shrink some if their location is below a certain point on the page however the simulated click function does not seem to be firing on the new elements.
Clicking the elements directly on the page does fire the click event so i believe they are bound to the event fine.
How can I get around this?
$.ajax({
url: filterurl,
type: "get",
type: "get",
data: {
ajax: "1",
filters: "1"
},
dataType: "json",
success: function(result) {
$(".filterloading").remove();
$(".sidebar").prepend(result['html']['filters']);
$('.filter-options-title').each(function(i, obj) {
if ($(this).offset().top + $(this).outerHeight() > ajaxMode.calculateHeight()) {
if ($(this).attr('aria-expanded') == 'true') {
$(this).click();
}
}
});
},
error: function() {
alert("Error please refresh page."); // inform the user about error
}
});