我有一个网页显示房屋的搜索结果,可以是详细视图(localhost:888#display-as-list),也可以在地图上显示(localhost:888#display-as-map),并可选择标签在两种观点之间。
我还有应用于搜索的过滤器,按属性价格排序或每页显示10,20,50等项目。更改这些过滤器后,将提交表单并刷新页面。
$(function () {
$('#selectsortorder,#numberofitems').change(function () {
$('#sortform').submit();
});
});
这个问题是当页面刷新新过滤器时,它会恢复到默认的详细视图(而不是地图视图)。有没有办法可以让表单提交一个重定向URL的类别,以便我可以找到选择哪个选项卡,然后转到localhost:888#display-as-list或localhost:888#display-as-map ?
$(function () {
$('#selectsortorder,#numberofitems').change(function () {
if ($('li[rel="display-as-list"]').hasClass("current")) {
$('#sortform#display-as-list').submit();
}
else {
$('#sortform#display-as-map').submit();
}
});
});
如果有更方便的方法,我也会在MVC / Razor中这样做。