0
我得到了一个包含对象列表(@contacts)的索引页,我需要能够使用ajax编辑弹出窗口中的每个@contact条目。对象列表:在rails中隐藏jQuery对话框
<% @contacts.each do |contact| %>
<div><%= contact.name %> | <%= link_to 'Edit', edit_contact_path(contact), :id => "edit_contact_dialog_link_#{contact.id}" %></div>
<% @contact = contact %><%= render :template => "contacts/edit" %>
<% end %>
这里我给所有编辑链接添加一个唯一的ID。这样做,以及在edit.html.erb
:
<div id="edit_contact_dialog_<%= @contact.id %>">
<h1>Editing contact</h1>
<%= render 'form' %>
</div>
现在索引页上我有一个联系人列表(具有唯一的编辑链接edit_contact_dialog_link_ID
),和编辑表单(具有唯一div编号edit_contact_dialog_ID
)
我需要隐藏所有edit_contact_dialog_ID
框和每个edit_contact_dialog_link_ID
点击打开相应的对话窗口,但不知道如何。
我contacts.js
:
$("#edit_contact_dialog_(here i need a regexp or smthng?)").dialog({
autoOpen: false,
width: 455,
modal: true
});
$("#edit_contact_dialog_link_???").click(function(){
$("#edit_contact_dialog_???").dialog("open");
return false;
});
感谢您的帮助。
太感谢你了! –