jQuery on() doesn't work on loaded inputs (datepicker)

jQuery on() doesn't work on loaded inputs (datepicker)

Hi!

I have a problem with loaded inputs. The datepicker doesn't show 

This is my code:


  1. $('.datepicker').on('click', function() {
  2.            $(this).datepicker({
  3.                 dateFormat: 'yy-mm-dd'
  4. }).focus();
  5.         });

This code works on the existing input but not on loaded elements.

Any suggestion?

PS: I'm using codeigniter and twitter bootstrap. Usually this code works but i don't know what's the problem here...

Thanks