0

App.modalRegionを表示する領域TopicView、講義リンクのリストを表示する CompositeView、sidebarおよびcontentリンクをクリックすると講義ビデオを再生する領域があります。すべて正常に動作しますが、VideoItemView別のリンクをクリックしても閉じません。

私の質問は: クリックでビデオ コンテンツが変更された場合、サブリージョンとリージョン内のレイアウトを使用せずに前のコンテンツを閉じることができるかどうか'.link'(マリオネットの魔法の方法の 1 つ) はありますか? コードは次のとおりです。VideoItemViewApp.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

新しい をレンダリングする直前に、が のインスタンスであるVideoItemViewかどうかを確認します。currentVideoItemViewVideoItemView

close次に、 でメソッドを呼び出し、currentVideoItemView新しいものをレンダリングしてから、 を再度VideoItemView設定currentVideoItemViewします。

于 2013-03-11T00:02:47.403 に答える