Skip Navigation

[Resolved] Scroll to achhor page on view search results

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 1 voice.

Last updated by Minesh 1 month, 3 weeks ago.

Assisted by: Minesh.

Author
Posts
#2800441

Hi, I have a view in home page ( weyourconsult.com ) and when I select a new page, if Form submint is "AJAX refresh when clicking submit", I lost contents.
So I tried to select "Full page refresh when clicking Submit" but I would like that page scroll to the view anchor like you can see year: hidden link

I've read:
https://toolset.com/forums/topic/adding-anchor-or-scrolltop-after-manual-pagnination-and-page-reload/
https://toolset.com/forums/topic/scroll-to-id-on-search-results-page/

If I put this code in Custom JS view section:
jQuery( document ).ready(function() {
jQuery('html, body').animate({ scrollTop: jQuery("#economia").offset().top-180}, 'slow');
});

always when I open weyourconsult.com the page scroll to #economia, but I would like that this happen only when I do some search or pagination view.

I tried also with this code in in Custom JS view section, but with no results:
jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function() {
jQuery( document ).ready(function() {
jQuery('html, body').animate({ scrollTop: jQuery("#economia").offset().top-180}, 'slow');
});
});

What can I try to change?

Many thanks, Marco.

#2800579

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

What if you try to add the following custom JS code and check if that help you to resolve your issue.

jQuery(document ).ready(function() {

jQuery.urlParam = function(name){
    var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
    if (results==null){
       return null;
    }
    else{
       return decodeURI(results[1]) || 0;
    }
}
 param =  jQuery.urlParam('wpv_view_count'); 
    if(param == 23302) {
          jQuery('html, body').animate({ scrollTop: jQuery("#economia").offset().top-180}, 'slow');

    }
});
#2800599

Hi Minesh, many thanks for your reply.
I tried to add the suggested Custom JS in View Block, but without success.

Do we try in another way?

Best regards, Marco.

#2800606

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please send me admin access details and problem URL and let me check whats going wrong with your setup.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2800628

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've adjusted the code to custom JS section of your view as given under:

jQuery(document ).ready(function() {
 
jQuery.urlParam = function(name){
    var results = new RegExp('[?&]' + name + '=([^&#]*)').exec(window.location.href);
    if (results==null){
       return null;
    }
    else{
       return decodeURI(results[1]) || 0;
    }
}
 param =  jQuery.urlParam('wpv_view_count'); 
    if(param == 23302) {
          jQuery('html, body').animate({ scrollTop: jQuery("#economia").offset().top-180}, 'slow');
 
    }
});

jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
	/**
	* data.view_unique_id (string) The View unique ID hash
	* data.effect (string) The View AJAX pagination effect
	* data.speed (integer) The View AJAX pagination speed in miliseconds
	* data.layout (object) The jQuery object for the View layout wrapper
	*/
  //jQuery("#economia").get(0).scrollIntoView({behavior: 'smooth'});
  jQuery('html, body').animate({ scrollTop: jQuery("#economia").offset().top}, 'slow');


	
});

Can you please confirm it works as expected. You can adjust the code as per your requirement.

#2800661

Hi Minesh, many thanks, it works!

If I make a search and then clic on Cancel it doesn't works.
How may I add also the cancel event?

Many thanks, Marco.

#2800966

Christopher Amirian
Supporter

Languages: English (English )

Hi,

This is Christopher. Minesh will be available tomorrow to answer the question.

Thank you for your patience.

#2801079

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

What if you try to use the following code and replace with the existing custom JS code added to your view's custom JS section and check if that also fixes the issue with cancel event:

jQuery(document ).ready(function() {
  
jQuery.urlParam = function(name){
    var results = new RegExp('[?&]' + name + '=([^&#]*)').exec(window.location.href);
    if (results==null){
       return null;
    }
    else{
       return decodeURI(results[1]) || 0;
    }
}
 param =  jQuery.urlParam('wpv_view_count'); 
 cancel_param = jQuery.urlParam('wpv_orderby'); 
    if(param == 23302 || cancel_param=='modified') {
          jQuery('html, body').animate({ scrollTop: jQuery("#economia").offset().top-180}, 'slow');
  
    }
});
 
jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
    /**
    * data.view_unique_id (string) The View unique ID hash
    * data.effect (string) The View AJAX pagination effect
    * data.speed (integer) The View AJAX pagination speed in miliseconds
    * data.layout (object) The jQuery object for the View layout wrapper
    */
  //jQuery("#economia").get(0).scrollIntoView({behavior: 'smooth'});
  jQuery('html, body').animate({ scrollTop: jQuery("#economia").offset().top}, 'slow');
 
 
     
});
#2801114
TooleSet IT View from Home Page.jpg
TooleSet CPT-Taxonomies.jpg
TooleSet View Box Overlap.jpg

Hi Minesh,
thanks for your update. Now seems good!
If I add text in search box (for example "Gestione") or select a taxonomy from advanced search, works well with search botton and cancel button.

I have other two problems with post view (let me know if is better to open different tickets).

In Home Page, selecting Italian language, I should have 19 post coming from 4 CPTs: Bus POSTS, Bus HOW-TOs, Bus TOOLS, Produc Post. When I open a new Home Page in pagination I can see 4 pages, and this is right because I set 6 post for page (3 pages with 6 post and 1 page with 1 post).

When I change page I loose 3 posts.
Some of them has member level restriction, but seems that it's not the problem.

With default ordering (last updated) in first page I can see "Scheda Obiettivi per Ruolo" (Level: INTEGRATOR), but I can't see FAQs KMS that hasn't level restriction.

If I change order to Title I CAN'T see "Scheda Obiettivi per Ruolo" (Level.: INTEGRATOR) and I CAN see FAQs KMS that hasn't level restriction!

I attach two images with a summary about that.

I've also seen that when I load home page if I select page 3, below in pagination, two posts are overlapping.
What can I do to resolve that? I attach image.

Many thanks, Marco.

#2801128

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

As per our support policy - we entertain only one question per ticket. This will help other users searching on the forum as well as help us to write correct problem resolution summery for the original issue reported with this ticket.

As oritinal issue is already addressed - May I kindly ask you to open a new ticket with every new question you may have. Thank you for understanding.