Skip Navigation

[Resolved] When filtering a view, jump to view location on page

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user has a filter on their page that refreshes the page to load the results but the user wanted to jump to the view after the page reloads.

Solution:

The solution to this can be seen in the link below.
https://toolset.com/forums/topic/when-filtering-a-view-jump-to-view-location-on-page/#post-1269425

This support ticket is created 5 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 2 replies, has 2 voices.

Last updated by orlaF 5 years, 7 months ago.

Assisted by: Shane.

Author
Posts
#1269315

When someone filters the view on this page (hidden link), I want the page to refresh and jump to where the view is displayed.

I have followed this support ticket: https://toolset.com/forums/topic/full-page-refresh-when-visitors-click-on-the-search-button-and-keep-position/

It doesn't seem to be working for me but I think it is for a different type of view. I just have a simple view that I need the page to jump down to.

This is the js that I added to my views JS Editor:

 the return value is assigned to QueryString!
  var query_string = {};
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
        // If first entry with this name
    if (typeof query_string[pair[0]] === "undefined") {
      query_string[pair[0]] = decodeURIComponent(pair[1]);
        // If second entry with this name
    } else if (typeof query_string[pair[0]] === "string") {
      var arr = [ query_string[pair[0]],decodeURIComponent(pair[1]) ];
      query_string[pair[0]] = arr;
        // If third or later entry with this name
    } else {
      query_string[pair[0]].push(decodeURIComponent(pair[1]));
    }
  } 
  return query_string;
}();
if(QueryString.wpv_view_count && QueryString.wpv_view_count == "596-TCPID97") {
  location.hash = "#licensed-coach-view";
}

Does it need to be different for a simple view?

Kind Regards,
Orla

#1269425

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Orla,

Try using this code below.

var getUrlParameter = function getUrlParameter(sParam) {
    var sPageURL = window.location.search.substring(1),
        sURLVariables = sPageURL.split('&'),
        sParameterName,
        i;

    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');

        if (sParameterName[0] === sParam) {
            return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
        }
    }
};

jQuery( document ).ready(function() {
var param = getUrlParameter('wpv-location');
if (param != null){
jQuery('html, body').animate({
        scrollTop: jQuery("#lm-filter").offset().top
    }, 2000);
}
});

Could you try this and let me know if it helps.

Thanks,
Shane

#1269449

My issue is resolved now. Thank you!