I managed to finally solved this. I called an RJS view from the controller
with insert_html :bottom.
On 11/13/06, Rizwan Reza
<rizwanreza-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> Hello,
>
> I am trying to make a category selection for an upload file so that a
> category can be selected according to the file being uploaded. The model
and
> upload is set up and I am able to select a category from upload.
>
> The problem is: I am making an ''add a category'' form
handled by ajax from
> the upload view. From the set up I have given below, I am able to add a
> category but can''t retrieve a selection field through Ajax. It
gets added
> upon refresh. Please review the setup below:
>
> In upload/new.rhtml view:
>
> Upload form (excerpt):
>
> <p id="select_category"><%= render :partial =>
''categories/select'' %></p>
>
> <p><%= submit_tag :Create %></p>
> <% end -%>
>
>
> Add category: <%= form_remote_tag :url => {
> :action => ''create_ajax'',
> :controller => ''categories''},
> :loading => "new
Effect.Appear(''indicator'', {
> duration: .3 })",
> :complete => "new
Effect.Fade(''indicator'', {
> duration: .3 })",
> :html => {
> :id => "category_ajax_form"} %>
> <%= text_field "category",
"title" %>
> <%= submit_tag :Create %>
> </form>
>
> In categories/_select.rhtml partial:
>
> <%= collection_select("category", @category,
Category.find(:all), "id",
> "title") %>
>
> And lastly, in controller, categories_controller.rb
>
> def create_ajax
> @category = Category.new(params[:category])
> if @category.save
> replace_html render_partial ''categories/select''
> else
> render category_path(@post), :layout => false
> end
> end
>
> Thanks in advance. I am sure there is a way out.
>
> Rizwan
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---