2013-08-01 69 views
0

I'm使用下劃線與由require.js與text.js加載HTML模板,如代碼波紋管:下劃線_,模板無法識別的模板變量

 template: _.template(listItemTemplate)  

     , render: function() { 
      $(this.el).html(this.template(this.model.toJSON)); 
      return this; 
     } 

tvListItemTemplate.html

<h4><%= _id%></h4> 

,如果我做的console.log(this.model.toJSON()),它打印以下內容:

enter image description here

但控制檯給我這個錯誤:

enter image description here

我不明白爲什麼

回答

0

對不起,但這是一個自己的愚蠢的錯誤:

$(this.el).html(this.template(this.model.toJSON ()));

1

請與:

$(this.el).html(_.template(listItemTemplate, this.model)); 

template: function(x) { 
     _.template(listItemTemplate, x); 
    }, 
    render: function() { 
     $(this.el).html(this.template(this.model)); 
     return this; 
    } 
+0

謝謝你的回答,但這是一個愚蠢的語法錯誤 – RMontes13