where does render :partial html end up

Total Post:110

 1740  View(s)
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"
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. Post:604

    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|


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.