Updating number field in the model

I have a post model with a number field named applause_counter

in my stimulus controller I can catch and print out the new value to the console log.


  increment() {
    var value = this.applause_counterTarget.value

    this.applause_counterTarget.textContent = value

But how can I update the model with the new value, after each click?

You should be able to set the value property on your number field:

this.applause_counterTarget.value = value

But I’m not sure if that’s what you’re asking, since your reading the value from that target in the first place. Exactly which element do you wish to update with the new value? :slight_smile: