0
개체 목록 (@contacts)이있는 색인 페이지가 있는데, 아약스를 사용하여 팝업에서 모든 @contact 항목을 편집 할 수있는 기능이 필요합니다. 개체 목록 :레일에서 id로 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 id를 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;
});
감사합니다.
너무 감사 class 속성을 사용! –