Start function and execute function again by clicking the button

1

When the page loads fully it starts a function, I would like that when clicking a button that same function would initialize again passing a text as Query String . I have the code:

$(document).ready(function() {

    function initMapplic(title){
        var mapplic = $('#mapplic').mapplic({
            source: '<?php echo base_url();?>assets/plugins/mapplic2/server.php?title='+title,    // Using mall.json file as map data
            sidebar: false,          // Enable sidebar
            developer:true,
            minimap: false,          // Enable minimap
            markers: true,         // Disable markers
            fillcolor: true,       // Disable default fill color
            fullscreen: true,       // Enable fullscreen 
            maxscale: 3             // Setting maxscale to 3
        });
    }

    initMapplic('');

    $("#searchfilters").on('click',function(){

        initMapplic('apertou');

    });


});

It starts normally, but when I click the button it does not appear to refresh by passing the text pressed as I would like.

    
asked by anonymous 04.08.2016 / 16:23

2 answers

0

Unselect the initMapplic function of the page load scope:

function initMapplic(title) {
    // ...
}

$(document).ready(function() {
    initMapplic('');

    $("#searchfilters").on('click', function() {
        initMapplic('apertou');
    });
});
    
04.08.2016 / 16:26
0

$(document).ready(function() {
    initMapplic("");
});
    
function initMapplic (title) {
  alert(title);
  var mapplic = $('#mapplic').mapplic({
    source: 'assets/plugins/mapplic2/server.php?title='+title,    // Using mall.json file as map data
    sidebar: false,          // Enable sidebar
    developer:true,
    minimap: false,          // Enable minimap
    markers: true,         // Disable markers
    fillcolor: true,       // Disable default fill color
    fullscreen: true,       // Enable fullscreen 
    maxscale: 3             // Setting maxscale to 3
  });
}
Veja se é mais ou menos isso que você precisa.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script><inputtype="button" onclick="initMapplic('apertou');" value="Enviar" />
    
05.08.2016 / 02:27