我的Treeview看起来像这样:它的haml
= @users.each do |user|
%ul
%li
= link_to user.name, #
= user.databases.each do |database|
%ul{:class => "database_user"}
%li{:id => database.id}
= link_to database.title + " ("+database.database_versions.length.to_s + " Versions )", #
= database.database_versions.each do |version|
%ul{:class => "database_versions"}
%li{:id => version.id}
= link_to version.created_at
$('。database_user li a')。click(function(s){
警报($(本).parent()ATTR( 'ID'));
返回false;
});
但我的警报显示未定义!
答案 0 :(得分:0)
尝试:
$('.database_user li a').click(function(s){
alert($("li:first",$(this).siblings("ul.database_versions")).attr("id");
}