这是我的问题。我想创建一个具有如下特定标题行的表
<table>
<tr class="table-header"> <th></th><th> Name </th><th> Location </th></tr>
..data..
</table>
当我想对表行进行Ajax填充时,问题就出现了。我试过几种选择。基本上,我的应用程序知道如何使用选择器(如表数据)插入数据。它会很好地更新,但会覆盖表头,或者将其全部插入一列,或者将其放在表头之上等。我尝试使用一个DIV来进行更新。
<p>
,
<tr>
等等,但似乎永远不会解决问题。
我的动作如下:
def multi_search
@profiles = Profile.find(:all) do
first_name =~ "%#{params[:profile][:first_name]}%" if params[:profile][:first_name].present?
last_name =~ "%#{params[:profile][:last_name]}%" if params[:profile][:last_name].present?
city =~ "%#{params[:profile][:city]}%" if params[:profile][:city].present?
state =~ "%#{params[:profile][:state]}%" if params[:profile][:state].present?
type =~ "%#{params[:profile][:type]}%"
paginate :page => params[:page], :per_page => params[:rows]
order_by "#{params[:sidx]} #{params[:sord]}"
end
render :partial=> "search/search_results", :collection => @profiles, :as=>:profile
end
我的javascript看起来是这样的:
$("#ajax_search_form").ajaxForm({target: '#provider_search_results'})
我的部分看起来是这样的:
<tr>
<td class="table_user_image"><%= image_tag profile.avatar.url(:small) %></td>
<td class="table_user_name">
<%= link_to_if(profile.user.role=="Provider", profile.full_name, { :controller => "profiles", :action => "show_public_provider", :id=>profile.id}) do
link_to(profile.full_name, { :controller => "profiles", :action => "show_public_student", :id => profile.id })
end %></td>
<td class="table_user_location"> <%= profile.city %>, <%= profile.state %> </td>
</tr>
在任何情况下,我想在到达集合之前,我需要呈现一些静态文本,我不知道该怎么做。任何帮助都将不胜感激。
注意:我正在使用Jrails