Underscoreテンプレートを使用しています。テンプレートとして外部ファイルを添付することは可能ですか?
バックボーンビューで私は:
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 ) })
しかし、それはうまくいきませんでした。