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 7716607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:40:39+00:00 2026-06-01T02:40:39+00:00

Update: I’ve fixed up my referencing below, and my problem is now more specific.

  • 0

Update:

I’ve fixed up my referencing below, and my problem is now more specific.

Background: I’ve got a set paths making up a map. Currently I have a visual on/off state when each region is clicked on, but I only want one region ‘active’ at any given time. I am calling a function which is meant to loop through all the regions, and change the fill colour of any non-active regions back to grey. Currently it seems to create a new set of paths when the following line is run: var obj = rsr.path(pathObj.path);. Below is a screen of the before and after.

The default state of the map

What happens when the map is clicked

I know this isn’t a rendering issue as the new paths are injected into the DOM.

This is my last hurdle on this project, I feel I’m so close!

You can view the page here: http://ochrerecruitment.com.s145292.gridserver.com/job-search/

This is the function I am running at the end of the click event (courtesy of Eliran Malka, thank you):

function onlyOneRegion() {
    for (var state in paths) {
            var pathObj = paths[state];
            var obj = rsr.path(pathObj.path);
            if (pathObj.active) {
                // do something
            } else {
                pathObj.active = false;
                obj.toFront();
                obj.animate({
                    fill: attributes.fill,
                    scale: 1,
                    'stroke' : '#fff',
                    'stroke-width' : 1,
                    transform: 's1'
                }, 150);
            }
    };
}

Thanks again!

Original Question:

I’ve currently got a map that sets a <select> value when clicked. Each region on the map also has a hover state and an on/off state.

The <select> functionality only allows one region to be active at any given time.

My problem is that I can’t figure out how to visually display only one active item. So on click, a region turns on, but I also want it to turn all other regions off.

My full function can be viewed here: http://pastie.org/3675997

The structure of each region is as follows:

var paths = {
    southisland: {
        name: 'southisland',
        path: 'coords',
        active: 'false'
    }

in my click event I have the following if else:

if (this.active) {
    this.active = false;
    this.animate({
        fill: attributes.fill,
        scale: '1',
        'stroke-width' : '1',
        transform: 's1'
    }, 150);                    
} else {
    this.active = true;
    this.animate({
        fill: '#e36f1e',
        scale: '1',
        'stroke-width' : '1',
        transform: 's1'
    }, 150);
}

straight after that I am trying to call the following function:

function onlyOneRegion() {
    for (var state in paths) {
        var obj = rsr.path(paths[state].path);
        if (state[active]) {
        } else {
            state[active] = false;

            obj.animate({
                fill: attributes.fill,
                scale: '1',
                'stroke-width' : '1',
                transform: 's1'
            }, 150);
        }
    };
}

This function doesn’t throw any errors, but doesn’t work wither.

Any help is greatly appreciated!

  • 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-01T02:40:40+00:00Added an answer on June 1, 2026 at 2:40 am

    I ended up solving the updated issue by rewriting my map creation into a function. Each time the a region is clicked on, It remembers that region, the deletes and re-creates the map, matching up the region with the relevant state id and making it active. Not the most elegant solution, but a solution nonetheless.

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

Sidebar

Related Questions

Update: Solved, with code I got it working, see my answer below for the
UPDATE: I've realized that the below problem only occurs if the user has already
Update: giving a much more thorough example. The first two solutions offered were right
Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
UPDATE : I updated the classes to look more like my actual model. When
Update 2: thanks again to @deepak-azad, I managed to solve my problem : here
UPDATE: Solution at bottom. I recently switched from using a set up such as
Update Table1 set name = (select top 1 a.col from Table2 a where Table1.num
UPDATE: Sorry I was wrong with my assumption of the problem. Its due to
Update: The multiple device screen dimensions is a red herring - the problem is

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.