Mixitup Multifilter显示问题与data-filter =“ all”

时间:2019-04-17 23:12:49

标签: jquery mixitup

我有一个简单的Mixitup设置,其中包含3个数据过滤器组:大小,位置和可用性。

位置组具有3个选项:所有位置,SOHO和NOMAD。

“所有位置”按钮的数据过滤器设置为“所有”。

如果单击“ soho”或“ nomad”,然后返回“所有位置”,则会在控制台上按原样输出“ .mix”类名,但是当我将“所有位置”与 size组合时 data-filter-group输出的过滤器是.classNameFromOtherFilterGroup all (在大小过滤器组的类名末尾添加了 all 字),因此不是有效的类名,则不显示任何内容。

当我单击“所有位置”和可用性过滤器组中的任何其他属性时,也会发生相同的问题,但是这次将“所有”一词附加到开头的所有 .classNameFromOtherFilterGroup

在两种情况下均不显示任何内容,因为该组合不是有效的选择器。我的代码如下:


fieldset {
  border: none;
  display: inline-block;
  padding: 0;
  margin: 0;
}

.private-office-container_controls-container {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  background: #f2f2f2;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 800;
  color: #252525;
  transition: background 150ms;
  border: 1px solid #979797;
}

.private-office-container {
  display: flex;
  flex-direction: column;
}

.private-office-container_item {
  display: flex;
  flex-direction: column;
  padding: 1em;
  text-align: left;
  background-color: white;
  color: #252525;
  border-bottom: 1px solid #979797;
  border-left: 1px solid #979797;
  border-right: 1px solid #979797;
}

.private-office-container_header {
  margin: 0;
  font-size: 1.3em;
}

.private-office-container_info {
  margin-bottom: 0;
  line-height: 1.4;
}

.private-office-container_form {
  display: flex;
  justify-content: space-between;
  margin-top: 1em;
}

.private-office-container_controls-item {
  display: flex;
  background-color: white;
  border: 1px solid #d2d2d2;
}

.private-office-container_controls-item>button,
.private-office-container_button {
  border: none;
  padding: 1em;
  background-color: transparent;
  -webkit-transition: all 0.2s ease-in-out 0s;
  transition: all 0.2s ease-in-out 0s;
}

.private-office-container_controls-item>button:hover {
  background-color: green;
  color: white;
}

.private-office-container_controls-item__size>button {
  padding: 1em;
  background-color: transparent;
  color: #252525;
}

.private-office-container_controls-text {
  position: relative;
  display: inline-block;
  width: 80px;
  margin: 0;
  padding: 1em;
  text-align: center;
  background-color: #D2D2D2;
}

.private-office-container_controls-text__size {
  position: relative;
  display: inline-block;
  margin: 0;
  padding: 1em;
  text-align: center;
  background-color: #D2D2D2;
}

.private-office-container_controls-text__header {
  text-align: center;
  font-size: 1.5em;
  margin: 0.5em;
  font-weight: 300;
}

.mixitup-control-active {
  background-color: green !important;
  color: white !important;
}
<head>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/mixitup/3.3.1/mixitup.min.js"></script>
<script src="https://sancar.work/mixitup-multifilter.min.js"></script>

  <script>
    var mixer = mixitup('.private-office-container', {
      multifilter: {
        enable: true
      },
      animation: {
        animateResizeTargets: true
      },
      callbacks: {
        onMixStart: function(state, futureState) {
          console.log(futureState.activeFilter.selector);
        }
      }
    });
  </script>

</head>

<body>
  <div class="private-office-container_controls-container">
    <p class="private-office-container_controls-text__header" style="display:none">Size of your team</p>
    <div class="private-office-container_controls-item private-office-container_controls-item__size" data-filter-group>
      <p class="private-office-container_controls-text__size">Size of your team</p>
      <button type="button" data-toggle=".filter-size-1">1 person</button>
      <button type="button" data-toggle=".filter-size-2-3">2 - 3 person</button>
      <button type="button" data-toggle=".filter-size-4-6">4 - 6 person</button>
      <button type="button" data-toggle=".filter-size-6-8">6 - 8 person</button>
      <button type="button" data-toggle=".filter-size-8-12">8 - 12 person</button>
      <button type="button" data-toggle=".filter-size-12">12+ person</button>
    </div>

    <form class="private-office-container_form">
      <div class="private-office-container_controls-item private-office-container_controls-item__location" data-filter-group>
        <p class="private-office-container_controls-text">Location</p>
        <button type="button" data-filter="all">All Locations</button>
        <button type="button" data-filter=".filter-location_soho-east">Soho East</button>
        <button type="button" data-filter=".filter-location_nomad">Nomad</button>
      </div>


      <div class="private-office-container_controls-item private-office-container_controls-item__date" data-filter-group>
        <p class="private-office-container_controls-text">Availability</p>
        <button type="button" data-toggle=".filter-availability_now">Now</button>
        <button type="button" data-toggle=".filter-availability_1mo">Within 1 month</button>
        <button type="button" data-toggle=".filter-availability_3mo">Within 3 months</button>
      </div>
      <button class="private-office-container_button" type="reset">See All</button>
    </form>
  </div>

  <div class="private-office-container">
    <div class="mix private-office-container_item filter-size-1 filter-location_soho-east filter-availability_now" data-order="1">
      <p class="private-office-container_header">1 Person Office</p>
      <p class="private-office-container_info">Available Now ● Soho East
        <br/> $750/mo
      </p>
    </div>
    <div class="mix private-office-container_item filter-size-2-3 filter-location_nomad filter-availability_3mo" data-order="2">
      <p class="private-office-container_header">2-3 Person Office</p>
      <p class="private-office-container_info">Available Now ● Nomad
        <br/> $1,250/mo
      </p>
    </div>
    <div class="mix private-office-container_item filter-size-4-6 filter-location_soho-east filter-availability_1mo" data-order="3">
      <p class="private-office-container_header">4-6 Person Office</p>
      <p class="private-office-container_info">In 1 month ● Soho East
        <br/> $2,750/mo
      </p>
    </div>
    <div class="mix private-office-container_item filter-size-6-8 filter-location_nomad filter-availability_3mo" data-order="4">
      <p class="private-office-container_header">6-8 Person Office</p>
      <p class="private-office-container_info">In 3 months ● Nomad
        <br/> $3,750/mo
      </p>
    </div>
    <div class="mix private-office-container_item filter-size-12 filter-location_soho-east filter-availability_now" data-order="5">
      <p class="private-office-container_header">16 Person Office</p>
      <p class="private-office-container_info">Available Now ● Soho East
        <br/> $9.500/mo
      </p>
    </div>
  </div>


</body>

我正在Squarespace上创建它-可能与Squarespace的JS代码冲突吗?

提前谢谢!

0 个答案:

没有答案