I have the classic case of: Posts, and Categories. When the user submits
a post, he has a drop-down list of categories. I want to put a “Add
category” link next to the list of categories.
This is already inside a form, so a “link_to_remote” that creates a
small AJAX form inside the “submit post” form will not work because that
will mean to embed a form in another form.
I can popup a window that at the end refreshes the parent window or go
to a page where the user can add categories and redirect at the submit
post, but that seems so ten years ago.
Can anybody enlighten me on what’s the “best practice” way to update
this categories list in a form? The web 2.0?
Yes, that’s the way I wanted to do it too, but Redbox was putting the
hidden popup div inside the main form, which I coudn’t get to work.
Do you have an example that you could post?
Cheers
Brad W.
On Mar 20, 3:14 pm, Constantin G. <rails-mailing-l…@andreas-
Yes, that’s the way I wanted to do it too, but Redbox was putting the
hidden popup div inside the main form, which I coudn’t get to work.
Do you have an example that you could post?
Cheers
Brad W.
Put a div named however you want outside your form.
In the form, use the :update => ‘div_id’ parameter. I used the redbox
convention of naming the div.
Then, you need to edit redbox_helper.rb. You need to get rid of all that
shit with “id” “hidden_id”, and use your variable that you given in
:update.
You also need to tell redbox not to generate the div for you. So you are
left with just two lines of code.
In my app I simply have a submit_to_remote within the larger form…
no need for a nested form. It submits the entire form including the
other fields but I only read the category[:name] param when I receive
it in my CategoriesController#create action.
I belive there is a :submit parameter available for submit_to_remote
that should specify which field(s) to submit instead of the whole
form, but I haven’t played with that. (See the API doc for
link_to_remote: as I understand it, submit_to_remote uses the same
options.)
On Feb 25, 12:07 pm, Constantin G. <rails-mailing-l…@andreas-
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.