rails 6 keep selected input after submitting

I am working on dynamic state-city select that city will change based on the selected state. My data is from city-state(https://github.com/loureirorg/city-state) gem.

For now, everything works well except that after I click on the "search" button, the selected city content will be reset to empty. I was wondering how to keep the selected city after submitting. Thanks.

form code

js code

what I expect after submitting

what I actually got

Source: Ask Javascript Questions

LEAVE A COMMENT