I want to load different partials with generated content into a form with ajax.
So how do i make this work?
For example, i have a form with the radio buttons “fruits” and “vegetablles”, so when i select one of them, the corresponding partial should be loaded directly into the template dynamically with the right content.
Its a simple form created with scaffolding (edit, show, destroy)
should be prototype normally?
All you do is :
In your controller, you should have the following methods:
Then, you should have your fruit.js.erb corresponding to that action (suppose you have jQuery here) :
You then need a partial view like _fruit.html.erb that contains the html you want
As Codeglot stated, if you want more precise answer, post more information about your problem. I cannot be more specific right now.