我在 Backbonejs 中有一个简单的添加事件,我也有模板:
initialize: function()
{
this.template = _.template($("#person-template").html());
}
renderperson: function(model)
{
//model.name is "Jack" for example
//Now I want to render this template with Name replaced with "Jack"?
$("#somelement").append( ); //What to do here???
}
模板很简单:
<script type="text/template" id="person-template">
<div class="person"><%= Name %></div>
</script>