refresh scroll position body

refresh scroll position body

Hello,

I’m learning jQuery. I use this template : http://www.youxithemes.com/themes/leviate and I made changes. The problem is

$( 'body' ).scrollspy( 'refresh' );

does not work. explanation : I load a page “creations.html” a div ”# containercrea” in the index.html page.

  1. $('a.creative').on('click', function() {
  2.       var url = $(this).attr('href');
  3.       $('#containercrea').load('creations.html');
  4. });


And I empty the div ”# containercrea” to click the “zw-nav” menu :

  1. $('#zw-nav').on('click', function() 
  2.       var url = $(this).attr('href');
  3.      $('#containercrea').empty('creations.html');
  4. });


Everything works, except that the values of the scroll #anchors are lost since the insertion of the contents of the div "#containercrea"changes the height of the page so the positioning div index.html the menu with anchors therefore does not work properly, it is lost ! I tried to do a refresh of the body:

  1. $('a.creative').on('click', function() {
  2.       var url = $(this).attr('href');
  3.       $('#containercrea').load('creations.html');
  4.       $( 'body' ).scrollspy( 'refresh' );
  5. });


I also tried

$( 'body' ).scrollTo( 'refresh' );


but no it does not work.

If it helps, here are the pieces of script with the word "scroll" that I found in the js used by the template (leviate.js).

  
  1. /* ==========================================================================

  2. ScrollSpy

  3. ============================================================================= */

  4. if( $.fn.scrollspy ) {

  5. $( 'body' ).scrollspy({

  6. target: '#zw-header'

  7. });

  8. $( window ).on( 'smartresize orientationchange', function() {

  9. $( 'body' ).scrollspy( 'refresh' );

  10. });

  11. }

  12. /* ==========================================================================

  13. ScrollTo

  14. ============================================================================= */

  15. if( $.fn.scrollTo ) {

  16. $( '#zw-nav, #work, #zw-header .brand, .slider-block .slide-link' ).on( 'click', 'a[href^="#"]', function(e) {

  17. var href = $( this ).attr( 'href' );

  18. var target = href === '#'? 0 : $( href );

  19. $( window ).scrollTo( target, {

  20. duration: $.isHandheld? 0 : 400

  21. });

  22. e.preventDefault();

  23. });

  24. }

Thank you kindly help me.

Mo