Home > DeveloperSection > Forums > where does render :partial html end up
Jayden Bell
Jayden Bell

Total Post:105

Points:739
Posted on    February-13-2013 1:14 AM

 ASP.NET MVC ASP.NET MVC 
Ratings:


 1 Reply(s)
 1108  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"
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

 



AVADHESH PATEL

Total Post:604

Points:4228
Posted on    February-13-2013 7:58 AM

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


Don't want to miss updates? Please click the below button!

Follow MindStick