는이 코드를 가지고 말할 수
$('a.clickers').live('click', function() {
///...
});
클릭 할 때 무엇을 당신이하고 싶은 것은 밖으로 하나의 요소이다. jquery의 핸들러 함수는 항상 해당 컨텍스트가 처리중인 요소 (즉, this == 앵커 요소)로 설정됩니다. 그래서 우리는 이것을 사용하고 그것을 개별적으로 호출해야합니다.
$('a.clickers').live('click', function clickHandler() {
// keep a reference to the link that is clicked on so we can refer to it
// later in the ajax handler.
var elementClickedOn = this;
// removes the live event handler
// from just this link
$(elementClickedOn).die('click', clickHandler);
// your code
// ajax call, im not 100% familiar with ajax in jquery
// but you get the gist.
$.ajax(server, function ajaxHandler(responseargs) {
if (responseargs.reEnableConditionMet) {
//renable the element's live event handler, by referring to the
//original function
$(elementClickedOn).live('click', clickHandler);
}
});
});
이 정보가 도움이되기를 바랍니다.
이것이 바람직한 지 궁금합니다. ".die()가 제대로 작동하려면 선택기가 .live()와 처음에 사용 된 선택기와 정확하게 일치해야합니다." [docs] (http://api.jquery.com/die/) – Casebash
이 게시물은 2 세입니다. 아마 그때 일했을 것입니다. – barkmadley