How to bind event on dynamic element


#1

i use Infinite Scroll to load items and every item need to bind click event, but binding is not working like ‘$$(’.item’).on(‘click’, function{})’, this ‘on’ does not like jquery ‘on’, it cant bind dynamic element. how can i do it gracefully? thanks


#2

do something like this

$$(document).on('click', 'a', function (e) {
  console.log('link clicked');
});