Hide jquery dialogs by id in rails -
i got index page list of objects(@contacts), , need ability edit every @contact entry in popup using ajax. list of objects:
<% @contacts.each |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 %>
here i'm adding unique id edit links. doing in edit.html.erb
:
<div id="edit_contact_dialog_<%= @contact.id %>"> <h1>editing contact</h1> <%= render 'form' %> </div>
now on index page have list of contacts(with unique edit links edit_contact_dialog_link_id
), , edit forms(with unique div ids edit_contact_dialog_id
)
i need hide edit_contact_dialog_id
boxes , on every edit_contact_dialog_link_id
click open corresponding dialog window, don't know how.
my contacts.js
:
$("#edit_contact_dialog_(here need regexp or smthng?)").dialog({ autoopen: false, width: 455, modal: true }); $("#edit_contact_dialog_link_???").click(function(){ $("#edit_contact_dialog_???").dialog("open"); return false; });
thanks help.
use class attribute
$(".dialog").dialog({ autoopen: false, width: 455, modal: true }); $(".edit_handler").click(function(){ var id = $(this).attr('id'); $("#edit_contact_dialog_" + id).dialog("open"); return false; });
Comments
Post a Comment