I'm trying to figure how I can use the each()
method to loop through dynamic elements. The method does not seem to be working if the element is not present. I do not wish to use setTimeout
either and would prefer something that would not delay the method or event.
So far all of the research and searching I've seen is using an event
handler to trigger on dynamic objects.
$('.task').each(function() {
let that = this;
// let startTask = $('.start-task', that);
let mc = new Hammer(this);
mc.on("panright", function(e){
if(e.deltaX < 100 ) {
$(that).css('transform', 'translateX(' + e.deltaX + 'px' + ')');
$(that).addClass('pan-task');
} else {
$(that).css('transform', 'translateX(100px)');
$('.start-task', that).trigger('click');
}
});
mc.on('panend', function(e){
$(that).css('transform', 'translateX(' + '0' + 'px' + ')');
$(that).removeClass('pan-task');
});
});