jqueryonclickmarkerjqvmap

Disable selected marker on jvectormap


I have a jvectormap and some markers, an external page would be loaded in a div whenever a marker is clicked and selected. I would like to enable only one marker at a time, right now the external page will reload every single time I click on the same marker, so I want to disable that (also change the pointer to cursor). Thanks!

markersSelectable: true,
markersSelectableOne: true,
...
onMarkerClick:function(event, id)
    { 
    // window.location.replace("links/'+code+'.html"); 
    $('#maincontent').load('links/loc'+id+'.html', function(){
            $('#maincontent').css('width', 0);
            $(this).animate({width: '27%'}, 200);
...

Solution

  • I'm not familiar with jvectormaps, but if I make some assumptions about your code and understand your question correctly, something like this might work:

    markersSelectable: true,
    markersSelectableOne: true,
    ...
    onMarkerClick:function(event, id) { 
    
        if ($("#maincontent").data('current-url') == 'links/loc'+id+'.html') {
            return false;
        }
    
        $("#maincontent").data('current-url', 'links/loc'+id+'.html')
            .load('links/loc'+id+'.html', function(){
                $('#maincontent').css('width', 0);
                $(this).animate({width: '27%'}, 200);
    ...