I was wondering. I’m generating a select box in my view where the user
can pick from a number of alternatives. However, I would like the last
option to be “Add new…” and then a box would pop up allowing the
user to enter a new value.
Now I’ve got all the JavaScript and the Rails code to allow the user
to enter a new option, the problem is how do I add the last
alternative (“Add new…”) to my select box?
Now I’ve got all the JavaScript and the Rails code to allow the user
to enter a new option, the problem is how do I add the last
alternative (“Add new…”) to my select box?
However, I would like the last option to be “Add new…”
and then a box would pop up allowing the user to enter a
new value.
Now I’ve got all the JavaScript and the Rails code to allow
the user to enter a new option, the problem is how do I add
the last alternative (“Add new…”) to my select box?
Assuming that the action that adds the new option creates a new record
in
the db and that you’re rendering a partial to display the select in the
first place (if not, refactor), just add a find to your action and
re-render
the select via RJS.
HTH,
Bill
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.