Dynamic nested form (new gem by me)

Hi, I want to share a gem that I’m working on.

https://github.com/arielj/vanilla-nested/

It’s a replacement of the cocoon gem (dymanic nested forms) but using only vanilla javascript so no jQuery dependency. I’m already using it on one of my projects and it has a few config options to customize it for different requirements.

You can find some examples on theREADME at github (it’s really similar to cocoon).

For now, it can only be added as a git repo (I’ll see how I can publish it as a gem on rubygems).

gem ‘vanilla_nested’, git: ‘https://github.com/arielj/vanilla-nested’, branch: ‘master’

I’d really really apreciate if you test it and can give me some feedback (ideally on github)!

Thanks!

2 Likes

Hey Ariel!

Good initiative! I think it would really come handy a GIF image with a visual example of how it does.

I suggest this because from the description I don’t get how would it be the look and feel of the nested form. Of course cocoon has the same issue.

An image is a thousand words and a GIF is a thousand images.

Congrats and keep it up. Removing JQuery dependency it’s a great plus.

Very nice.

Hi! The look and feel does not depend on the gem, it just adds/removes some html (defined by the user) to/from an specific container when you click a button. The actual look depends on the form defined and styled by the user. I’ll try to add a gif with an use example though, thanks!!

pretty cool, I was using a jQuery based one and moved to stimulus, greatest choice I ever made I think:

inspired from: https://github.com/gorails-screencasts/dynamic-nested-forms-with-stimulusjs/blob/master/app/javascript/controllers/nested_form_controller.js