0

我有一个App.modalRegion显示的区域TopicView,一个显示讲座链接列表的 CompositeView,sidebar以及一个content在单击链接时播放讲座视频的区域。一切正常,但是VideoItemView单击另一个链接时不会关闭。

我的问题是:当点击更改视频内容时'.link',是否存在(其中一种木偶的神奇方式)可以在不使用子区域和区域内布局的情况VideoItemView下关闭前一个。这是代码:App.modalRegion

App.modalRegion.show( new TopicView({ model: topicModel }) );

TopicView = new Backbone.Marionette.CompositeView.extend( {

  template: tpls.TopicTpl,

  ui: {
    sidebar: "#topic-sidebar",
    content: "#topic-content"
  },

  initialize: function(){
    this.listenTo(this.model, "change", this.render);
  },

  onRender: function(){
    this.showContent();

    var collection = this.model.get('lectures'),
      that = this;

    this.ui.sidebar.on('click','.link',function(e) {
      e.preventDefault();
      var sno = $(this).data("sno");

      var vid = new VideoItemView({
        model: collection.get(sno),
        lec_sno: sno
      });

      that.ui.content.html(
        vid.render().el
      );
    });
  },

  showContent : function() {

    var list = new LectListCol({ 
      collection: this.model.get('lectures')
    });

    this.ui.sidebar.html(
      list.render().el
    );
  }

});
4

1 回答 1

0

我会向您添加一个属性,该属性TopicView将引用您的currentVideoItemView.

Just before you render the new VideoItemView, you would check to see if currentVideoItemView is an instance of VideoItemView.

Then you would call the close method on the currentVideoItemView, render your new VideoItemView and then set the currentVideoItemView again.

于 2013-03-11T00:02:47.403 回答