Home > Blockchain >  I want to add dynamic text fields in rails 7 using stimulus JS
I want to add dynamic text fields in rails 7 using stimulus JS

Time:11-08

Could you please help me in this question because I don't have any idea about it. As a beginner in stimulus js I don't have much idea about it.

I need the answer of above question.

CodePudding user response:

Hi could you tell us what do you mean by 'dynamic text fields'. What should be dynamic about them. If you want to be able to add more text fields as you click on a button - you can try cocoon (it uses jquery, but works really good)

https://github.com/nathanvda/cocoon

I know that you ask Stimulus solution, but this one is pretty good library as well.

Good luck !

CodePudding user response:

The Stimulus homepage shows you how to fill in a text field and it outputs dynamically in another field.

You'll need to put code in a view and make a file for the JS code as per their example.

Their guide here provides step-by-step: https://stimulus.hotwired.dev/handbook/hello-stimulus

Is this what you need? What else is the issue or where are you most stuck?

  • Related