높음!
내가하고 싶은 일은 다음과 같습니다. 나는 onclick이있는 테이블을 짝수 행의 테이블에있는 링크에 연결했습니다. 홀수 행은 모두 숨겨져 있습니다. 해당 링크를 클릭하면 홀수 행이 표시되고 데이터가 해당 행에로드됩니다. 잘 작동합니다.
이제 내가하고 싶은 것은 해당 프로세스가 완료 될 때마다 해당 링크에 새로운 클릭 기능을 추가하여 행을 다시 숨겨야한다는 것입니다. 일종의 토글 (toggle)과 비슷하지만, 몇 가지 기능 만 추가하면 표시/숨기기 기능이 있습니다. 다음 코드를 사용하여 작업하려고했지만 작동하지 않습니다.
나는 아주 기본적인 것을 놓치거나 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();
});
}
그것은 테이블 행을 열고 다시 행을 종료하는 기능을 부착하지 않는 한 다음 데이터를 삽입하지만. 어떻게 이런 일이 일어날 수 있습니까?
아이디어가 있으십니까?
거룩한 쓰레기! 그게 그랬어. 고마워. –