Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8637853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:34:44+00:00 2026-06-12T10:34:44+00:00

I wonder whether someone may be able to help me please. I’m am relatively

  • 0

I wonder whether someone may be able to help me please.

I’m am relatively new to JavaScript programming, so I ask please for your patience.

I’ve put together this page, which allows users to add or remove Google Map markers via ‘Marker Category’ check box selection. In addition to the relevant markers being added and removed from the map, the description for each marker is added or removed from a ‘Sidebar; which is shown in orange text.

If the user clicks on the ‘Sidebar’ item, the info window for the relevant marker will be displayed, and if the marker is selected, the relevant description in the sidebar listing will be highlighted with a grey background.

The problem I have is if a user selects a marker on the map the sidebar doesn’t automatically scroll to the item relevant list item as shown in the example on this page.

I am using a third party script to create the scroll bar which is shown in the code below:

<script>
        (function($){
            $(window).load(function(){
                $("#sidebar").mCustomScrollbar({
                    scrollButtons:{
                        enable:true
                    }
                });
                //ajax demo fn
                $("a[rel='load-content']").click(function(e){
                    e.preventDefault();
                    var $this=$(this),
                        url=$this.attr("href");
                    $.get(url,function(data){
                        $("#sidebar .mCSB_container").html(data); //load new content inside .mCSB_container
                        $("#sidebar").mCustomScrollbar("update"); //update scrollbar according to newly loaded content
                        $("#sidebar").mCustomScrollbar("scrollTo","top"); //scroll to top
                    });
                });
                $("a[rel='append-content']").click(function(e){
                    e.preventDefault();
                    var $this=$(this),
                        url=$this.attr("href");
                    $.get(url,function(data){
                        $("#sidebar .mCSB_container").append(data); //append new content inside .mCSB_container
                        $("#sidebar").mCustomScrollbar("update"); //update scrollbar according to newly appended content
                    });
                });
            });
        })(jQuery);
</script>

and this is the section of code that links the map marker and sidebar item.

google.maps.event.addListener(marker, 'click', function() { 
  infowindow.setContent(contentString);
  $("#sidebar a").css('background-color','');//remove sidebar links back colors
  sidebarlink = $("#sidebar a:contains('"+marker.mydescription+"')");
  sidebarlink.css('background-color','#DADADA');
  infowindow.open(map,marker); 
});

I have tried to put a overflow item in both areas, hoping that this would solve the problem. In addition, I’ve also omitted the following lines to see whether I could come up with a solution:

$("#sidebar").mCustomScrollbar("update"); //update scrollbar according to newly loaded content                          
$("#sidebar").mCustomScrollbar("scrollTo","top"); //scroll to top

Unfortunately my attempts haven’t solved the issue.

I just wondered whether someone may be able to look at this please and let me know where I’m going wrong.

Many thanks and kind regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:34:45+00:00Added an answer on June 12, 2026 at 10:34 am

    Just add the following line, to your marker click event handler:

    $("#sidebar").mCustomScrollbar("scrollTo","a:contains('"+marker.mydescription+"')");
    

    so your code would look like:

    google.maps.event.addListener(marker, 'click', function() { 
      infowindow.setContent(contentString);
      $("#sidebar a").css('background-color','');//remove sidebar links back colors
      sidebarlink = $("#sidebar a:contains('"+marker.mydescription+"')");
      sidebarlink.css('background-color','#DADADA');
      $("#sidebar").mCustomScrollbar("scrollTo","a:contains('"+marker.mydescription+"')");
      infowindow.open(map,marker); 
    });
    

    that should scroll to your clicked item.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder whether someone may be able to help please. I'm a little new
I wonder whether someone may be able to help me please. Firstly apologies as
I wonder whether someone may be able to help me please. I'm using the
I wonder whether someone may be able to help me please Firstly, my apologies
I wonder whether someone may be able to help me please. Firstly, this is
I wonder whether someone may be able to help me please. Firstly, my apologies
I wonder whether someone may be able to help me please. I feel I
I wonder whether someone may be able to help me please. Firstly my apologies.
I wonder whether someone may be able to help me please. I'm using Aurigma
I wonder whether someone may be able to help me please. I've put together

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.