My backbone view folder:
view.html
tmpl/t01.html
tmpl/t02.html
tmpl/t03.html
view.html:
...
<div id="tmpl"></id>
in view.html, when I click button 01, I would like to display tmpl/t01.html within view.html, How can I do that?
My backbone view folder:
view.html
tmpl/t01.html
tmpl/t02.html
tmpl/t03.html
view.html:
...
<div id="tmpl"></id>
in view.html, when I click button 01, I would like to display tmpl/t01.html within view.html, How can I do that?
これは ajax リクエストで手動で処理できます。
$.ajax({
url: 'tmpl/t01.html',
dataType: 'text',
success: function(data){
var compiledTpl = _.template( data, {} );
$('#tmpl').html(compiledTpl);
}
);}
または、require.js のテキスト プラグインを使用
require(["text!tmpl/t01.html"],
function(html) {
var compiledTpl = _.template( html, {} );
$('#tmpl').html(compiledTpl);
}
);