WHERE DOES RENDER :PARTIAL HTML END UP

Jayden Bell

Total Post:110

Points:774
Posted by  Jayden Bell
 1368  View(s)
Ratings:
Rate this:

Hi Everyone!

I have a view with an Ajax form:

<%= form_tag( {:action => 'some_action'}, {:remote => true}) do %>
...
  <%= submit_tag "Submit" %>
<% end %>
Now, in the target action, I want to display a partial

def some_action
  # some logic
  render :partial => "some_partial"
end
The partial is just html. _some_partial.html.erb could be

<br>Hi, this is the partial</br>
When I submit the form, I see the html response packet is received in the browser (with firebug's net logs), but the html doesn't show up anywhere. Where

should the html be? How to render a partial html view from an action?

Please help ASAP.

Thanks in advance

 

  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: where does render :partial html end up

    Hi Jayden!

    you are not define place where partial view will be render

    Try this way

    create a file named some_action.js.erb and write the code in it:

    // update div with id some_div_id
    $("#some_div_id").html("<%= escape_javascript(render :partial => 'some_partial') %>");
    in controller

    def some_action
      # some logic
      respond_to do |format|
        format.js
      end
    end

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!