0

Zombie RUN!などの DOM からビューを削除する方法の手がかりを検索して見つけました。そして他の投稿。その後、そのうちの 1 つを選択して、ここでリンクを実行しました。

これが私の見解です:

var HomeView = Backbone.View.extend({
   initialize: function() {
       myCart1.updateQtyLabel("qtyCart");
       window.localStorage.setItem("User",serializeObjToJSON(customer));
   },
   el: '#webbodycontainer',
   events : {
       "click #addToCart" :  function(){
           myCart1.addToCart(newItem);
           myCart1.updateQtyLabel("qtyCart");
           $("#containernewpromotion").html(promotionItem);
       }
   },
   render : function(){
       this.$el.html(homePanel);
       $("#containernewpromotion").html(promotionItem);
   },
    remove: function() {
        this.undelegateEvents();
        this.$el.empty();
        this.stopListening();
        return this;
    }
});
return HomeView;

そして、これは私のルーターです:

app_router.on('route:home', function( ){
    var homeView = new HomeView();
    homeView.remove();
    homeView = new HomeView();
    homeView.render();
 });

しかし、ビューはまだ私のDOMにとどまります。この問題についてのアイデアをお願いします。ありがとう。

4

1 に答える 1