2013-06-03 180 views
0

我GOOGLE和GOOGLE上搜索,沒有運氣,試圖找出爲什麼我有這個在我的Backbone.js的應用程序:爲什麼我的Backbone.js模型屬性嵌入爲HTML屬性?

<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 

回答

0

好的事實證明,你需要通過hash進入initialize方法,不只是模型對象。它應該是...

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

......還有......

_handleOrderAdded: (order, orders) => 
    orderCardView = new BehindTheBarApp.Views.OrderCardView({order: order}) 
相關問題