0

我用谷歌搜索和搜索,没有运气试图弄清楚为什么我在我的主干.js 应用程序中有这个:

<div id="114" number="R462134068" line_items="[object Object]" status="ready" customer_name="John Doe" confirmation_code="PIMMS43" total="3.8" created_at="Fri May 10 2013 08:26:18 GMT+0100 (BST)" class="order-card-container">...

...这通常表明我遗漏了一些明显的东西。有任何想法吗??

这是我观点的开始(CoffeeScript):

class BehindTheBarApp.Views.OrderCardView extends Backbone.View
  @LATE_ORDER_WATCHER_INTERVAL_MS: 1000

  className: 'order-card-container'
  template: JST["behind-the-bar-app/templates/order_card"]

  initialize: (order) =>
    @order = order

    # ...

而在另一个视图中加载模型的行...

_handleOrderAdded: (order, orders) =>
  orderCardView = new BehindTheBarApp.Views.OrderCardView(order)

  newItems = orderCardView.render().$el
  @$el.append( newItems )
      .isotope( 'reloadItems' ).isotope({ sortBy: 'original-order' })

  @_orderCardViews.push orderCardView
4

1 回答 1

0

好的,事实证明您需要将哈希传递给initialize方法,而不仅仅是模型对象。它应该是...

initialize: (options) =>
  @order = options.order

...和...

_handleOrderAdded: (order, orders) =>
    orderCardView = new BehindTheBarApp.Views.OrderCardView({order: order})
于 2013-06-03T10:08:51.947 回答