在 UIKit 中按组重置过滤器

发布于 2025-01-13 19:30:17 字数 4954 浏览 0 评论 0 原文

您能否告诉我是否可以以某种方式仅重置一组的 UIKit 过滤器。例如,我有一组过滤器,我想单击“Dct”专门针对数据颜色组重置过滤器,但不重置大小。 如果添加 uk-filter-control 参数并将其设为空,则所有元素都会重置,有没有办法做不同的事情

<div uk-filter="target: .js-filter">

  <div class="uk-grid-small uk-grid-divider uk-child-width-auto" uk-grid>
          <div>
          <ul class="uk-subnav uk-subnav-pill" uk-margin>
            <li class="uk-active" uk-filter-control><a href="#">Dct</a></li>
          </ul>
        </div>
    <div>
      <ul class="uk-subnav uk-subnav-pill" uk-margin>
        <li uk-filter-control="filter: [data-color='white']; group: data-color"><a href="#">White</a></li>
        <li uk-filter-control="filter: [data-color='blue']; group: data-color"><a href="#">Blue</a></li>
        <li uk-filter-control="filter: [data-color='black']; group: data-color"><a href="#">Black</a></li>
      </ul>
    </div>

    <div>

      <ul class="uk-subnav uk-subnav-pill" uk-margin>
        <li uk-filter-control="filter: [data-size='small']; group: size"><a href="#">Small</a></li>
        <li uk-filter-control="filter: [data-size='medium']; group: size"><a href="#">Middle</a></li>
        <li uk-filter-control="filter: [data-size='large']; group: size"><a href="#">Big</a></li>
      </ul>
    </div>

  </div>

  <ul class="js-filter uk-child-width-1-2 uk-child-width-1-3@m uk-text-center" uk-grid="masonry: true">

    <li data-color="white" data-size="large">
      <div class="uk-card uk-card-default uk-card-body">
        <canvas width="600" height="800"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="blue" data-size="small">
      <div class="uk-card uk-card-primary uk-card-body">
        <canvas width="600" height="400"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="white" data-size="medium">
      <div class="uk-card uk-card-default uk-card-body">
        <canvas width="600" height="600"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="white" data-size="small">
      <div class="uk-card uk-card-default uk-card-body">
        <canvas width="600" height="400"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="black" data-size="medium">
      <div class="uk-card uk-card-secondary uk-card-body">
        <canvas width="600" height="600"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="black" data-size="small">
      <div class="uk-card uk-card-secondary uk-card-body">
        <canvas width="600" height="400"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="blue" data-size="medium">
      <div class="uk-card uk-card-primary uk-card-body">
        <canvas width="600" height="600"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="black" data-size="large">
      <div class="uk-card uk-card-secondary uk-card-body">
        <canvas width="600" height="800"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="blue" data-size="large">
      <div class="uk-card uk-card-primary uk-card-body">
        <canvas width="600" height="800"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="white" data-size="large">
      <div class="uk-card uk-card-default uk-card-body">
        <canvas width="600" height="800"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="blue" data-size="medium">
      <div class="uk-card uk-card-primary uk-card-body">
        <canvas width="600" height="600"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="black" data-size="small">
      <div class="uk-card uk-card-secondary uk-card-body">
        <canvas width="600" height="400"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
  </ul>

</div> 

Can you please tell me if it is possible to somehow reset the UIKit filter filter for only one group. For example, I have a group of filters and I want to click on "Dct" to reset the filter specifically for the datacolor group, but not size.
If you add the uk-filter-control parameter and make it empty, then all the elements are reset, is there a way to do something differently

<div uk-filter="target: .js-filter">

  <div class="uk-grid-small uk-grid-divider uk-child-width-auto" uk-grid>
          <div>
          <ul class="uk-subnav uk-subnav-pill" uk-margin>
            <li class="uk-active" uk-filter-control><a href="#">Dct</a></li>
          </ul>
        </div>
    <div>
      <ul class="uk-subnav uk-subnav-pill" uk-margin>
        <li uk-filter-control="filter: [data-color='white']; group: data-color"><a href="#">White</a></li>
        <li uk-filter-control="filter: [data-color='blue']; group: data-color"><a href="#">Blue</a></li>
        <li uk-filter-control="filter: [data-color='black']; group: data-color"><a href="#">Black</a></li>
      </ul>
    </div>

    <div>

      <ul class="uk-subnav uk-subnav-pill" uk-margin>
        <li uk-filter-control="filter: [data-size='small']; group: size"><a href="#">Small</a></li>
        <li uk-filter-control="filter: [data-size='medium']; group: size"><a href="#">Middle</a></li>
        <li uk-filter-control="filter: [data-size='large']; group: size"><a href="#">Big</a></li>
      </ul>
    </div>

  </div>

  <ul class="js-filter uk-child-width-1-2 uk-child-width-1-3@m uk-text-center" uk-grid="masonry: true">

    <li data-color="white" data-size="large">
      <div class="uk-card uk-card-default uk-card-body">
        <canvas width="600" height="800"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="blue" data-size="small">
      <div class="uk-card uk-card-primary uk-card-body">
        <canvas width="600" height="400"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="white" data-size="medium">
      <div class="uk-card uk-card-default uk-card-body">
        <canvas width="600" height="600"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="white" data-size="small">
      <div class="uk-card uk-card-default uk-card-body">
        <canvas width="600" height="400"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="black" data-size="medium">
      <div class="uk-card uk-card-secondary uk-card-body">
        <canvas width="600" height="600"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="black" data-size="small">
      <div class="uk-card uk-card-secondary uk-card-body">
        <canvas width="600" height="400"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="blue" data-size="medium">
      <div class="uk-card uk-card-primary uk-card-body">
        <canvas width="600" height="600"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="black" data-size="large">
      <div class="uk-card uk-card-secondary uk-card-body">
        <canvas width="600" height="800"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="blue" data-size="large">
      <div class="uk-card uk-card-primary uk-card-body">
        <canvas width="600" height="800"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="white" data-size="large">
      <div class="uk-card uk-card-default uk-card-body">
        <canvas width="600" height="800"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="blue" data-size="medium">
      <div class="uk-card uk-card-primary uk-card-body">
        <canvas width="600" height="600"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
    <li data-color="black" data-size="small">
      <div class="uk-card uk-card-secondary uk-card-body">
        <canvas width="600" height="400"></canvas>
        <div class="uk-position-center">El</div>
      </div>
    </li>
  </ul>

</div> 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北座城市 2025-01-20 19:30:17

以下是 UIkit Github 存储库中所需场景的示例。有两个按钮 - 一个用于过滤,一个用于重置列表。这些按钮还可以切换彼此的可见性,以便用户一次只能看到一个。

https://github.com/uikit/uikit-site/pull/173/ files

相关代码如下。请注意第二个最初隐藏的按钮,其中 uk-filter-control 设置为空白 filtergroup: one;过滤器:

<button uk-filter-control="group: one; filter: [data-meta~='one']"
        uk-toggle="target: .my-filter-control-one"
        class="my-filter-control-one uk-button">
    One
</button>               
<button uk-filter-control="group: one; filter: "
        uk-toggle="target: .my-filter-control-one"
        class="my-filter-control-one uk-button uk-button-primary"
        hidden>
    One
</button>

Here's an example of the desired scenario in the UIkit Github repo. There are two buttons - one which filters and one which resets the list. The buttons additionally toggle the visibility of each other, so that only one is seen by the user at a time.

https://github.com/uikit/uikit-site/pull/173/files

The relevant code is below. Notice the second, originally hidden button, where the uk-filter-control is set with a blank filter value group: one; filter: .

<button uk-filter-control="group: one; filter: [data-meta~='one']"
        uk-toggle="target: .my-filter-control-one"
        class="my-filter-control-one uk-button">
    One
</button>               
<button uk-filter-control="group: one; filter: "
        uk-toggle="target: .my-filter-control-one"
        class="my-filter-control-one uk-button uk-button-primary"
        hidden>
    One
</button>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文