ASP.NET MVC 2:模拟 eBay 回发
下面是我正在讨论的部分的图片:
我所做的与 eBay 非常相似:
1)顶部的“搜索词”表单和然后是一个类别。
2) 左侧的过滤器,用户可以单击以进一步细化搜索。
3)对这些结果进行排序。
我玩了一下 eBay,在我看来,每次单击过滤器(左侧的框)或对结果进行排序时,他们都会发回信息。然后,他们是否存储用于在表单中显示页面的所有“设置”的副本,并使用它在提交点击时发回?
我怎样才能模拟这个功能?我不喜欢将整个页面包装在 form
元素中的想法......它看起来很脏。我应该使用 jQuery 收集所有用户输入,然后以某种方式传递它吗?
Below is an image of the sections I'm talking about:
What I'm doing is very similar to eBay:
1) a form at the top for "search terms" and then a category.
2) filters on the left that a user can click to refine the search even further.
3) sorting those results.
I played with eBay a bit and it looks to me like they are posting back every time a filter (box on the left) is clicked, or when they sort the results. Do they then store a copy of all the "settings" used to display the page in the form and use that to post back on a submit click?
How can I emulate this functionality? I don't like the idea of wrapping an entire page in a form
element... it seems dirty. Should I use jQuery to collect all of the user input and then somehow pass it along?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定 eBay 是如何做到的,但如果是我,我会有一些 javascript 对象来跟踪页面上的所有搜索选项。您突出显示的每个元素都会触发一个事件,该事件会导致我的 javascript 对象更新此信息,通过 AJAX 将其发送到控制器操作,并使用更改更新结果区域。
这是事件的简化版本,但希望它能让您走上正轨。
I'm not sure how eBay does it, but if it were me, I'd have some javascript object that keeps track of all the search options on the page. Each of the elements you've highlighted would fire an event that would cause my javascript object to update this information, send it via AJAX to a controller action, and update the results area with the changes.
That's a somewhat simplified version of events, but hopefully it can put you on the right track.
我决定最好的解决方案是使用 jQuery Ajax。否则,我必须确保每个用户输入都是
form
元素,并将整个页面包装在form
标记中。I've decided that the best solution is to use jQuery Ajax. Otherwise, I'd have to make sure that every peice of user input is a
form
element and wrap the entire page in aform
tag.