Ability to check if a field has already been rendered

  • 1
  • Problem
  • Updated 3 years ago
  • Not a Problem
I have a field in my page and I am overriding the handleChange method for the field with some fairly complex behavior.

Part of this behavior depends on the data in another model. So I need to be able to call the snippet that sets up my field when certain events are thrown.

The issue is right now, I am getting duplicate instances of the field (and the entire editor it belongs to for that matter - see attached screen grab).

I belive this is because I am calling render multiple times.

So what I need is logic to be able to tell if the field has been previously rendered or not, and only render the first time if that makes sense, and simply override the handleChange function otherwise.

Any help on this would be appreciated.

Photo of Hamza Tayeb

Hamza Tayeb

  • 278 Points 250 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Hamza Tayeb

Hamza Tayeb

  • 278 Points 250 badge 2x thumb
Never mind, got it sorted. It was not the multiple field.render() calls that was causing this.
I simply had been creating new rows in the model!

Mystery solved.
Photo of Anna Wiersema

Anna Wiersema

  • 10,890 Points 10k badge 2x thumb
Thanks for letting us know, Hamza!