All threads / Dropdown menu with form data?

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Dropdown menu with form data?

Christian Kienast asked in Javascript

Hey there,

I'm building a dropdown menu for a form, that looks something like this:

  • Entry 1
  • Subset
    • Entry 1
    • Entry 2
  • Entry 2

The selected option has to be in the params later on.

I'm a React dev and know how to build the dropdown menu itself, but how do I wire JS and Rails in this case?
Do I need an AJAX controller, only for the menu? How do I use it in JS?

Solved it..

I just had honey in my head.

All you have to do is render a hidden field that you update on click and just render all ul's and li's and toggle their display with jQuery.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 34,674+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.