0

I have a paper card in a dom-repeat. I have a button that adds a new person using an Ajax call. In the response I use this.push to add it to the person array. This then triggers the dom-repeat to add a new paper-card.

The paper-cards have an id= "person_+[index]. In my Ajax response; after this.push, I attempt to get the newly added person paper-card element with the id using queryselector but it's does no exist and returns null, so I am unable to call scrollToView(). It's like the paper-card isn't stamped and the added person index does not exist. How can I add a person, trigger the dom-repeat, get the new ID and use scrollToView to go to the newly created paper-card. Thanks

PrakashG
  • 1,642
  • 5
  • 20
  • 30
  • Could you please add your code in order to inspect whether exist an error or not. I think giving Id seam not correct. – Cappittall Jan 06 '19 at 09:01

1 Answers1

0

You need to pospone the code after the push until the element has been rendered.

Do this using the updateComplete promise

See the documentation reference

vals
  • 61,425
  • 11
  • 89
  • 138