I'm walking into a large Backbone.js project so I'm still getting my bearings. My template, my-group-item.jhbs has:

{{#if isComplete}}
.row-fluid
  .span2
    img.entity-image(src="/pictures/{{entityId}}.png")

  .span10
    .row-fluid
      .span12
        h3 {{entityName}}
        p My first variable {{totalFirst}} and my second variable {{totalValue}}

{{/if}}

My View is:

module.exports = class MyItemView extends View
  className: ->
    templateData = @getTemplateData()
    primaryData = @model.get('primaryData')
  tagName: 'li'
  template: require 'views/my-group-item'

  initialize: () ->
    super
    primaryData = @model.get('primaryData')

In my template, the totalFirst and totalValue variables show nothing.

I'm calling my view with:

  @groupView = new MyItemView
    collection: groups
    el: '.group-list'

How can I get these to show in the template?

有帮助吗?

解决方案

You could pass more than 1 variable to your template, the first being your model and the second being the attributes of primaryData.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top