I have a webpage that displays search results of houses as either a detailed view (localhost:888#display-as-list) or altogether on a map (localhost:888#display-as-map), with tabs to choose between the two views .

I also have filters to apply to the search, sort by price of property or display 10, 20, 50, etc, items per page. When these filters are changed, the form is submitted and the page refreshes.

$(function () {
    $('#selectsortorder,#numberofitems').change(function () {
        $('#sortform').submit();
    });
});

The problem with this is that when the page refreshes with the new filters, it reverts to the default detailed view (instead of maybe the map view). Is there a way that I could have the form submit with a redirect URL of sorts so that I can find which tab is selected and then go to either localhost:888#display-as-list or 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();
        }
    });
});

I'm also doing this in MVC/Razor if there is any way to do that more conveniently.

Related posts

Recent Viewed