高い!
私がやりたいことは次のとおりです。偶数行のテーブルにあるリンクにonclickが接続されたテーブルがあります。奇数行はすべて隠されています。そのリンクをクリックすると、奇数行が表示され、データがその行にロードされます。正常に動作します
今私がやりたいことは、そのプロセスが完了するたびに、そのリンクに新しいクリック機能を追加して、行を再び非表示にすることです。トグルのようなものですが、さらに機能を表示/非表示にします。次のコードでそれをやろうとしましたが、うまくいきません。
私は確かに非常に基本的なことを見逃しているか、jqueryを十分に知らないだけです(数週間前に始めたばかりなので、これは非常に可能です)。
$(document).ready(function(){
// The version icons
$("a.version").click(function () {
var sLink = $(this).attr("href");
var nexttr = $(this).parent().parent().next("tr.version");
var nexttrtd = nexttr.find("td:first");
$.get(sLink, function(sData){
nexttrtd.html(sData);
nexttr.show();
});
$(this).click(function(){
attachHideMyChildren();
});
return false;
});
});
function attachShowMyChildren()
{
var sLink = $(this).attr("href");
var nexttr = $(this).parent().parent().next("tr.version");
var nexttrtd = nexttr.find("td:first");
$.get(sLink, function(sData){
nexttrtd.html(sData);
nexttr.show();
});
$(this).click(function(){
attachHideMyChildren();
});
return false;
}
function attachHideMyChildren()
{
$(this).parent().parent().next("tr.version").hide();
$(this).click(function(){
attachShowMyChildren();
});
}
テーブルの行を開き、データを挿入しますが、行を再び閉じる関数は添付しません。どうすればこれを実現できますか?
何か案は?