0

I would like to use the jquery autocomplete function on a field of a form collection. For example, I have a form collection that got those fields: name product, price.

I would like to use the autocomplete function on name product field. The problem is that when I load the page, this field doesn't exist because it's created after I click on "add product button". Then it will be created with this id: invoice_products_0_name where the number 0 is the id of the collection. I should use the autocomplete in all the collection.

Can you suggest me something?

Timo Tijhof
  • 9,867
  • 6
  • 33
  • 47
Francesco
  • 41
  • 7

1 Answers1

0

To bind DOM that is not yet created, you can use jquery on function as described here.

Add a class on your product_name input field. Then you can bind the function to the futur DOM like that

$('#your-form-collection').on('focus', '.input-name-autocomplete' function () {
         $(this).YourLibAutocomplete()
});
Community
  • 1
  • 1
goto
  • 7,454
  • 10
  • 46
  • 54