我无法让 ItemView 呈现我在 testMap 中定义的值。我想要的只是将 1、2、3 动态插入到<ol class='test-list'>
标签中,<li>
这样我的 html 看起来就像
<ol class="test-list">
<li>1</li>
<li>2</li>
<li>3</li>
</ol>
我错过了什么?
testMap =
a: '1'
b: '2'
c: '3'
class TestLayout extends Layout
template: require '/test_template'
regions:
body: 'section'
events:
'click #testme': 'test'
test: -> app.vent.trigger 'test'
class TestItemView extends ItemView
template: require '/test-item'
serializeData: -> {testMap}
class TestListView extends CollectionView
tagName: 'ol'
className: 'test-list'
itemView: TestItemView
module.exports = class TestPlugin extends Application
testList: null
initialize: =>
@test = new Collection
app.vent.on 'test', @showTest, @
showTest: ->
app.layout.test.show @layout = new TestLayout
@layout.body.show @testList= new TestListView collection: @test
我的名为 test-item 的 Html 文件如下所示:
<span class='test'>
<%= @testMap %>
</span>
我所有的全局变量都在扩展文件中定义。
我认为这里的罪魁祸首是我无法让我的收藏绑定到我的 itemView。因此,当我调用@showTest
函数时,我什么也得不到,因为我的 testMap 对象没有与我的@test
变量对话。我怎样才能把这两个对象结婚?
@layout.body.show @listView = new TestListView collection: @test