I'm new to rails, and I've got my application up and running. Now I'd
like to add a function that I haven't been able to find information
on.
Basically, I start with a form that asks the user to input the number
of widgets of some type they have.
For example (____ is a textfield):
_____ widgets of type ______.
Then I want to have a link below this that says "Add more widgets."
This would insert another line between the above and the "Add more
widgets" link. This would be able to be repeated as many times as the
user wants to enter widgets of many different types. Also, the new
lines should appear without refreshing the page.
Any help is appreciated. I hope this is the right forum. I figure
this will take some AJAX. I've done something similar before with
JavaScript, but it just hid/unhid a div.
I'm new to rails, and I've got my application up and running. Now I'd
like to add a function that I haven't been able to find information
on.
Basically, I start with a form that asks the user to input the number
of widgets of some type they have.
For example (____ is a textfield):
_____ widgets of type ______.
Then I want to have a link below this that says "Add more widgets."
This would insert another line between the above and the "Add more
widgets" link. This would be able to be repeated as many times as the
user wants to enter widgets of many different types. Also, the new
lines should appear without refreshing the page.
Any help is appreciated. I hope this is the right forum. I figure
this will take some AJAX. I've done something similar before with
JavaScript, but it just hid/unhid a div.
You don't need Ajax just to add more input fields: there's usually no
reason to make a server request for something so simple. It can be done
completely on the client side -- look at Element.clone() .