0

I'm working with the following plugin: http://jqvmap.com/ with brought me a proper map of a country with its distinct regions.

I want to refresh the page with post data to filter some information when a click occurs. I used the load function which seems pretty easy to use but even if the function is reached, nothing happens afterwards.

Here is the jQuery:

$(document).ready(function() {
    $('#francemap').vectorMap({
        map: 'france_fr',
        hoverOpacity: 0.5,
        hoverColor: "#EC0000",
        backgroundColor: "#444444",
        color: "#FACC2E",
        borderColor: "#000000",
        selectedColor: "#EC0000",
        enableZoom: false,
        showTooltip: true,

        onRegionClick: function(element, code, region)
        {
            var url = "home";
            $(document).load(url, {region:region});
        }
    });
}); 

So if I basically clic on a region: nothing happens. Even thought the onRegionClick function is reached.

My bet is that it is a "DOM level issue" like i'm calling the document selector inside the $("#francemap") but I can't make sure and moreover I don't know how to overcome this.

Thank you for reading me

Aldhyr
  • 43
  • 4

1 Answers1

1

If you want to refresh the page, u need

window.location = url+"#"+region;

 

$(document).load(function() {}) 
// Bind an event handler to the "load" JavaScript event.

Here's an example

slashsharp
  • 2,823
  • 2
  • 19
  • 26
  • Thanks for the fiddle, it obviously works but the struggle is that I need a post action solution. Function load was perfect for it since a form is too heavy for that and a window.location implies a url modification. – Aldhyr Jul 06 '15 at 09:55
  • why don't you use ajax to post the data – slashsharp Jul 06 '15 at 12:36
  • load is an Ajax method, isn't it? I don't get why it doesn't work – Aldhyr Jul 06 '15 at 12:49