Hide or Remove the Empty Wishlist from the wish list

If you want to hide the empty wish list from the list

Extend the Product listlists view and MenuTree view

_.extend(ProductListListsView.prototype, {

          childViews: _.extend({}, {

            ‘ProductList.ListDetails’: function () {

              var self = this;

              self.collection.models = _.reject(self.collection.models,

                function (items) {

                  return items.attributes.items.length == 0;

                });

              return new BackboneCollectionView({

                childView: ProductListListDetailsView,

                viewsPerRow: 1,

                collection: this.collection

              });

            }

          })

        });

        _.extend(MenuTreeView.prototype, {

          //This view is extended to hide emty wishlist .

          getContext: _.wrap(MenuTreeView.prototype.getContext, function (fn) {

            try {

              var original = fn.apply(this, _.toArray(arguments).slice(1));

              var menuItem = original.menuItems;

              for (let i = 0; i < menuItem.length; i++) {

                if (menuItem[i].id === “productlists”) {

                  if (menuItem[i].children && menuItem[i].children.length > 0) {

                    menuItem[i].children = menuItem[i].children.filter(function (child) {

                      return child.name.indexOf(‘(0)’) === 1;

                    });

                  }

                }

              }

            } catch (e) {

              console.log(“err@MenuTreeView”, e);

            }

            return original;

          })

        });

Leave a comment

Your email address will not be published. Required fields are marked *