在 Sitecore 中使用 AJAX 过滤页面内容

发布于 2024-08-24 19:18:43 字数 190 浏览 2 评论 0原文

我在 Sitecore 中有一个页面显示客户列表。有一个带有两个选择框的表单,可以过滤掉不符合指定条件的客户。每次用户更改表单中的值之一时,或者如果禁用 JS,则在单击“提交”按钮后,应通过 AJAX 刷新客户端列表。

为了在 Sitecore 中实现此功能,我应该采取什么建议方法?我不确定 Sitecore 部分,我知道如何调用 AJAX 方法/

I have a page in Sitecore that displays the list of clients. There's a form with two select boxes that should filter out clients not matching specified criterias. Clients list should be refreshed via AJAX everytime user changes one of the values in the form or after clicking Submit button if JS is disabled.

What is the suggested approach I should take to have this working in Sitecore? I'm not sure about Sitecore part, I know how to call AJAX methods/

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

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

发布评论

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

评论(3

吻风 2024-08-31 19:18:43

我找到了一个比其他人在这里提出的解决方案感觉更好的解决方案。我在 Sitecore 中创建了一个新设备,在其中创建了一个新布局,其中我刚刚添加了一个占位符。然后我可以使用此方法访问所有网站内容。并且分配 URL 参数 a=1 会使所有具有此参数的 URL 自动重定向到该设备。我不认为它可以变得更简单。

I found a solution that feels a bit better then what other have proposed here. I've created a new Device in Sitecore, created a new layout in it in which I just added one placeholder. Then I can access all site content using this method. And assigning a URL parameter a=1 makes all URLs with this param automatically redirect to this device. I don't think it can be made much simpler.

淡淡の花香 2024-08-31 19:18:43

如果您使用的是 Sitecore + ASP.NET Webforms,那么最快/最简单的解决方案就是使用 .NET UpdatePanel。它不是最灵活的 AJAX 解决方案,但它确实可以以最小的努力完成工作。请参阅文档

如果您在 Sitecore 中使用 XSL 渲染,解决方案会更加复杂。您可能需要创建一个仅列出客户端的新渲染,然后使用 JQuery 检索并替换 DOM 的该部分。

If you're using Sitecore + ASP.NET Webforms, your quickest/easiest solution is simply to use a .NET UpdatePanel. It's not the most flexible AJAX solution but it certainly gets the job done, with minimal effort. See the documentation.

If you are using XSL Renderings in Sitecore, the solution would be more complicated. You'd likely need to create a new Rendering what just lists the clients, then use JQuery to retrieve and replace that section of the DOM.

丶情人眼里出诗心の 2024-08-31 19:18:43

根据您的问题,我假设该页面最初会显示要过滤的客户的完整列表。如果是这样,您是否需要从服务器获取更多数据?看来这是重复的努力。这就是我要做的:

为每个客户端创建一个 div,其中包含代表过滤类别的类:

<div class="client design development">Microsoft</div>
<div class="client design">Apple</div>

然后,当每个过滤器更改时,根据类选择器显示/隐藏 div。根据目标浏览器和/或 js 库,您也许能够使用 CSS 属性选择器。

From your question, I assume the page will initially display a full list of clients to be filtered down. If so, do you need to fetch any more data from the server? It seems that's duplicating effort. Here's what I'd do:

Create a div for each client, with classes representing the filtering categories:

<div class="client design development">Microsoft</div>
<div class="client design">Apple</div>

Then, when each filter is changed, show/hide the divs based on class selectors. Depending on the target browser and/or js library, you may be able to use CSS attribute selectors.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文