I recently got a problem that
$('.klass').change(function () { ... });
was not firing in some situations and found the solution on SO to use
$(document).on('change', '.klass', function () { ... });
instead. The explaination was that my element was created after declaration of the listener or something else was blocking it from firing.
So I should probably never use the first method? And use the second method for any event (click, change, ...):
$(document).on('event', 'jquery-selector', function () { ... });
Could someone please explain the difference between the two and possible gotchas.