2013-03-15 3 views
0

이 jQuery 템플릿을 underscorejs 템플릿으로 변환하려고했지만 왜 작동하지 않는지 이해가되지 않습니다. 왜 그 이유를 설명 할 수 있습니까?이전에서 변환시 언더 코어 템플릿 오류가 발생했습니다.

 el: $('#contents'), 
    template: _.template(MenuTemplate), 
    //template: $('#item-tmpl').template(), 

    render: function() 
    { 
    this.$el.empty(); 

    //$.tmpl(this.template, this.model.toArray()).appendTo(this.el); 
    // Old jquery template 


    //this.$el.html(this.template(this.model.toArray()).appendTo(this.el)); 
    //underscore template 

     return this; 
    } 
+0

어떤 문제가 있습니까? 나는 템플릿을 사용하고 루트 요소에 설정하는 기술을 이해하지 못한다. ('appendTo'에 대한 호출은 불필요하다.) 예제는 [here] (http://backbonejs.org/#View-render)를 참조하십시오. – WiredPrairie

답변

1

템플릿 사용에 약간의 어려움이 있습니다. 사용해보기 :

el: $('#contents'), 
template: _.template(MenuTemplate), 

render: function() 
{ 
    this.$el.empty(); 

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

    return this; 
} 
+0

이전에 크롬을 시도했지만 크롬에 오류가 있습니다. 'Uncaught ReferenceError : 위치가 정의되지 않았습니다' – koko

+0

여기가 backbonejs 웹 사이트 https://www.dropbox.com/s/ixk4htvgenx87y0/bbgek.zip에서 가져온 샘플입니다. – koko

관련 문제