How do I properly store a javascript template, so that it isn't instantiated multiple times

后端 未结 6 385
一整个雨季
一整个雨季 2021-02-03 12:44

I\'m using Backbone and therefore Underscore to render my templates. My templates get rendered in

6条回答
  •  孤街浪徒
    2021-02-03 12:55

    Another solution using prototype:

     initialize: function(option) {
         if (!this.template) App.ItemView.prototype.template = this.template || _.template($('ItemTemplate').html());
     }
    

提交回复
热议问题