2013-12-09 8 views
1

JSON 데이터의 내용을 가져 오기 위해 간단한 핸들을 추가했지만 콘솔에 "TypeError : this._input is undefined"오류가 표시됩니다. 당신이 console.log(source)한다면 그때는 정의되지 않은 반환합니다 ..TypeError : this._input이 Handlebars에서 정의되지 않았습니다.

<div class="profileSectionhandle"> 
    <script id="profileTabs" type="text/x-handlebars-template"> 
      {{#profilecontent}} 
      ....... 
      {{/profilecontent}} 
      </script> 
    </div> 

var source = $("#profileTabs").html(); 
var template = Handlebars.compile(source); 
$(".profileSectionhandle").html(template(data)); 

답변

0

을 스피 올바른 출력을 받고,하지만 여전히 나는 항상 이러한 오류를 얻을. 즉, 코드가 실행될 때 $("#profileTabs").html()이 DOM에 없으면 undefined을 컴파일하려고합니다.

js가 귀하의 핸들 바를 호출 할 때까지 페이지가로드되지 않을 가능성이 있습니다. 웹 앱 (jquery)을 사용하는 경우 $(document).ready(function() {...})에 함수를 배치하거나 모바일 애플리케이션 (jquery 모바일 사용)의 경우 $(document).bind("pagebeforeshow", function() {...})에 함수를 배치하십시오.

관련 문제