저는 현재 작은 styleguide 응용 프로그램에서 작업 중이며 기능의 일부는 특정 모듈이 iframe에로드 될 수있는 샌드 박스 영역이 있다는 것입니다 미디어 쿼리를 시뮬레이션). 이제이 콘텐츠는 iframe이 관련 스타일 및 스크립트와 함께 생성 된 후에 동적으로 삽입됩니다.콘텐츠를 삽입 한 후에 Iframe의 클릭 핸들러가 작동하지 않습니다.
비 이벤트 처리기 스크립트는 경고 상자와 같이 잘 작동하지만 클릭 핸들러는 작동하지 않는 것 같습니다. Jquery는 괜찮아서로드가 배제되었습니다. 그것의 부모로부터
이
코드는 iframe을의 HTML 안에 직접 넣어되고, 코드의 샘플을 그냥 명확히<!-- Accordion-->
<div class="accordion module-suggestions col-sm-3 col-xs-12 pull-right hidden-xs">
<h4>Most popular</h4>
<div class="accordion-section active">
<ul>
<li>Why your CCTV could land you in jail<span class="result-type case-study"></span>
</li>
<li>How to measure performance of SMEs<span class="result-type guides"></span>
</li>
<li>How to measure performance <span class="result-type checklist"></span>
</li>
</ul>
</div>
<h4>Most recent</h4>
<div class="accordion-section">
<ul>
<li>Why your CCTV could land you in jail<span class="result-type case-study"></span>
</li>
<li>How to measure performance of SMEs<span class="result-type guides"></span>
</li>
<li>How to measure performance <span class="result-type checklist"></span>
</li>
</ul>
</div>
<h4>Recommended</h4>
<div class="accordion-section">
<ul>
<li>Why your CCTV could land you in jail<span class="result-type case-study"></span>
</li>
<li>How to measure performance of SMEs<span class="result-type guides"></span>
</li>
<li>How to measure performance <span class="result-type checklist"></span>
</li>
</ul>
</div>
</div>
<!--/Accordion -->
<script>
function accordion() {
var accordion = $('.accordion h4');
var accordionSection = $('div.accordion-section');
$(accordion).on("click", function(e) {
if (!$(this).next(accordionSection).is(":visible")) {
$(accordionSection).is(":visible") && $(accordionSection).slideUp();
$(this).next(accordionSection).slideDown();
}
});
}
accordion();
</script>
을 삽입, 나는 그것을 호출하고 있지 않다. .
는 Iframe으로 HTML/JS를 삽입해야하는 코드 :
iframePreview.contents하면() 검색 ("HTML") HTML (libraryScripts + '\ n'+ moduleHtmlAndJs).
이러한 클릭 핸들러를 어떻게 기능적으로 만들 수 있습니까?
어디에서 accordion()을 (를) 호출합니까? –
스크립트 태그 내의 전체 내용이 iframe 내에서 실행 중입니다. –
대리인 클릭 이벤트 : http://learn.jquery.com/events/event-delegation/ –