1
Django와 Django Endless Pagination 및 Twitter 스타일로드를 사용하고 있습니다. 내 연구에서 읽은 것처럼 .on 및 .delegate를 사용 했음에도 불구하고 새로 삽입 된 요소에 바인딩 할 jQuery 코드를 가져올 수 없습니다. 나는 그것의 비난받는 상태 때문에 .live를 피했다. 그러나 명백하게 .on과 .delegate는이 상황에서 같은 일을 어떻게해서든지해야한다..on 및 .delegate가있는 경우에도 jQuery가 Ajax로드 요소에 적용되지 않음
기본적으로 제품 검색 결과는 Endless Pagination이 삽입하는 카드로 표시됩니다.
관련 코드 조각 :
JS
$(".product-card").on('click',function() {
cardToggle = $(this).data("switch");
if (cardToggle==0) {
// some stuff happens to the card
$(this).data("switch", 1);
}else if(cardToggle==1) {
// some stuff un-happens to the card
$(this).data("switch", 0);
}
})
제품 목록 (아약스 메인 페이지에로드의 템플릿)
{% load static %}
{% load endless %}
{% paginate results %}
{% for result in results %}
{# divs with class .product-card are created here, code for card removed because of prohibitive length #}
{% endfor %}
{% show_more %}
완벽한 교체, 감사합니다! _document_이 부모가되어야한다는 것을 알지 못했습니다. 이전에 해당 구문을 사용하여 click을 시도했지만 parentselector로 직접 상위 컨테이너를 사용했습니다. – DiscRiskandBisque
@ViousAmbitious - 도와 드리겠습니다. 도움이 되었기 때문에 내 대답을 upvote하시기 바랍니다 :) [부끄러움, 내가 아니야] – Krishna
처음에 시도했지만, 그렇게하려면 15 가지 평판이 필요하다고합니다. :^( – DiscRiskandBisque