0

I need to add an event listener on paste to all elements with a specific class.

I used this simple javascript:

var fields = document.getElementsByClassName('ui-inputfield');

to get all the elements, and then for each element this one:

addEventListener('paste', handlePaste);

Where is the problem:

The funtion starts on page load, but at that moment, i don't have all the elements rendered.

When some conditions render another element with that class, this element doesn't have the paste event handled.

I use Primefaces to render or not the elements.

Someone can suggest any solution?

Thanks in advance!

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102

0 Answers0