Search code examples
javascriptjqueryruby-on-railsjvectormapjqvmap

Rails/Javascript: JQueryVector Map Not Loading on Page Load


On my rails application I am using JQV map to display a world map with some data. Only problem is, the map is not loading when I load the page, it only loads if I press `ctrl + shift + r. I have it set to load on page load in my application.html.erb file, like so.

<!-- Jvector Map -->

<script>
$(document).on('ready page:load', function(){
    jQuery('#vmap').vectorMap({
    map: 'world_en',
    backgroundColor: null,
    color: '#ffffff',
    hoverOpacity: 0.7,
    selectedColor: '#666666',
    enableZoom: true,
    showTooltip: true,
    values: numberYouth,
    scaleColors: ['#ffffff', '#006491'],
    normalizeFunction: 'polynomial',
    onLabelShow: function (event, label, code) {
        if (numberYouth[code] > 0)
            label.append(': '+numberYouth[code]+' Youth');
    }
});
});
</script>

EDIT: I also noticed that a few other Javascript things do not seem to be loading without reloading the page. For a few pages, I have things like javascript objects (which hold the country data from this map for example) in a separate javascript file. For even a single variable, do I have to have these in a page load bracket function?

You can view the live app here. here.

Anyone have any ideas on why it isn't loading?


Solution

  • I had some problems loading tinymce on my app. It was caused by turbolink, problem was gone after i disabled it for that particular page.