Filtering out page content with AJAX in Sitecore

一曲冷凌霜 提交于 2019-12-23 02:48:13

问题


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/


回答1:


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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/2408567/filtering-out-page-content-with-ajax-in-sitecore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!