How to render a partal after form load

<% @departmentinfo = Department.find_all_by_company_id( @user.company_id, :order => "department_name ASC" ) %> <%= render( :partial => 'departments', :object => @departmentinfo, :locals => { :userinfo => @user } ) if @departmentinfo %> <%= observe_field("userinfo_department_id", :on => "changed", :url => {:action => :update_roles}, :with => "'department_id='+value")%> Dear all In my above code all the department gets loaded before the form gets loaded. I want to render my partial after the document is loaded completely. i am not sure how to do this.. Kindly help me out

The short answer is, you can’t - all <% … %> code is run, then the
page is
displayed.

The long answer is, you could, but there’s probably a better solution.
The
way you could do this is to add an event to the document’s onload event
How to call scripts - Unobtrusive Javascript that
does an ajax call to the controller that renders the partial.