2016-06-04 2 views
0

내 레이아웃에 Template.contentBlock을 사용하고 있고 Fullcalendar onRendered를 호출하려고합니다.jquery는 MeteorJS의 Template.contentBlock에서 작동합니까?

CONSOLE.LOG 레이아웃이 표시되지만 fullCalendar 참조 또는 행을 변경하는 것도이

Template.userAppointments.onRendered(function() { 
    console.log('userAppointments rendered') 
    $('#calendar').fullCalendar(); 
    $('.row').css("background-color","blue"); 
}); 

<template name="layout"> 
{{#if appReady}} 

<div class="container-fluid"> 
    {{>header}} 
    {{>errors}} 
    <div class="row"> 
     <div class="col-md-2"> 
      {{> sidebar}} 
     </div> 
     <div class="col-md-10"> 
      {{> Template.contentBlock}} 
     </div> 
    </div> 
</div> 

{{else}} 
{{>loading}} 
{{/if}} 

템플릿. 이것은 jquery가 Template.contentBlock에서 어떻게 든 벽돌을 만들었다 고 생각하게 만듭니다.

계몽에 미리 감사드립니다.

+0

무엇이'console.log ($)'에 의해 인쇄됩니까? – 4castle

+0

@ 4castle (selector, context) {// 70 \t \t // jQuery 객체는 실제로 '향상된'초기화 생성자입니다 ... – Chris

+1

템플릿의 jQuery 객체에 대한 참조를 사용하려면 명시 적으로 'this. $'를 사용해야합니다. . 따라서 코드의이 부분은 잘 작동합니다. 'onRendered' 함수에 중단 점을 넣고'$ ('. row')'와'$ ('# calendar')'이 반환하는 것을 확인하십시오. 확실히 그들은 거기 있지 않습니다 (아마'appReady'가 false입니까?). – Julien

답변

0

문제점을 파악했습니다. 구독이 준비되었는지 확인하는 userAppointments 템플릿 내에서 패턴을 사용하고있었습니다.

도우미

Template.userAppointments.helpers({ 
    ready: function() { 
    return Template.instance().subscriptionsReady(); 
    } 
}); 

템플릿

<template name="userAppointments"> 
    {{#if ready}} 
    ... 
    {{/if}} 
</template> 

어떤 이유로위한 onRendered 함수 실행 jQuery를 차단이 패턴.

관련 문제