我收到了一個'Missing itemViewContainer'錯誤,我並不期待。我的模塊如下所示:木偶:意外失蹤itemViewContainer
@App.module 'InstagramApp.List', (List, App, Backbone, Marionette, $, _) ->
class List.ItemView extends Marionette.ItemView
template: '#instagram_item_template'
class List.CompositeView extends Marionette.CompositeView
el: '#bb-instagram'
className: 'large-3 medium-6 columns projects__project'
events:
'click .js-next-photo': 'handleNextClick'
'click .js-prev-photo': 'handlePrevClick'
handleNextClick: (e) ->
e.preventDefault()
console.log 'next photo'
handlePrevClick: (e) ->
e.preventDefault()
console.log 'previous photo'
template: '#instagram_list_template'
itemView: List.ItemView
itemViewContainer: '#bb-photos-container'
而且我的模板看起來像這樣:
<script id="instagram_list_template" type="text/template">
<div class="bg-pattern photos">
<div class="photos__inner">
<h4 class="photos__header">I.Instagram</h4>
<div id="bb-photos-container"></div>
<a href="#" class="photos__button photos__button--next js-next-photo"><img src="/assets/img/vendor/photos-btn-next.png" alt=""></a>
<a href="#" class="photos__button photos__button--prev js-prev-photo"><img src="/assets/img/vendor/photos-btn-prev.png" alt=""></a>
</div>
</div>
</script>
所以我#bb-photos-container
元素顯然是定義...有什麼想法,什麼是怎麼回事?
我在這裏稱之爲:
@App.module 'InstagramApp.List', (List, App, Backbone, Marionette, $, _) ->
List.Controller =
listPhotos: ->
photos = App.request 'photo:entities'
instagramView = new List.CompositeView({ collection: photos })
$('#bb-projects-list').append(instagramView.render())