12
เทมเพลตภายนอกในเครื่องหมายขีดล่าง
ฉันใช้แม่แบบขีดล่าง เป็นไปได้ที่จะแนบไฟล์ภายนอกเป็นเทมเพลต ? ใน Backbone View ฉันมี: textTemplate: _.template( $('#practice-text-template').html() ), initialize: function(){ this.words = new WordList; this.index = 0; this.render(); }, ใน html ของฉันคือ: <script id="practice-text-template" type="text/template"> <h3>something code</h3> </script> มันทำงานได้ดี แต่ฉันต้องการแม่แบบภายนอก ฉันลอง: <script id="practice-text-template" type="text/template" src="templates/tmp.js"> หรือ textTemplate: _.template( $('#practice-text-template').load('templates/tmp.js') ), หรือ $('#practice-text-template').load('templates/tmp.js', function(data){ this.textTemplate = _.template( data …