2013-12-09 21 views
1

我已經添加了一個簡單的Handlebar來從JSON數據中獲取內容,但是iam在控制檯中收到此錯誤 - 「TypeError:this._input is undefined」。 IAM得到正確的輸出,但我仍然一直得到這些錯誤..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

如果你要console.log(source),那麼它將返回undefined。這意味着$("#profileTabs").html()不在DOM中,我的代碼運行的時間,然後您試圖編譯undefined

有可能您的頁面在您的js調用您的手柄時沒有加載。如果您正在使用jquery的Web應用程序,或者使用$(document).bind("pagebeforeshow", function() {...})(使用jQuery移動版),請將您的功能置於$(document).ready(function() {...})之中。

相關問題