I am trying to use pikaday on dynamically generated input element. However it initiates infinite loop making the page unresponsive. Here is my code
$(document).on('focus', '.slcDate', function(){
new Pikaday({
field:this
})
})
Each time you focus an .slcDate input element, You basically initialize a new instance of Pikaday on that element.
It doesn't seem like the plugin itself has any protection for that case and instead it just run into infinite loop. So better make sure that you don't initialize Pikaday plugin more than once on a given element.
Example (by simply adding .initialized class as a flag to filter against):
$(document).on('focus', '.slcDate:not(.initialized)', function(){
new Pikaday({
field: this
});
$(this).addClass("initialized");
});