0
follows my code
    var canvasEvents = new Object;  
    canvasEvents['05-30-2015'] = '<a href="#" target=_blank>CAMPEONATOS SUL-AMERICANOS DE ATLETISMO</a>';
    $.getJSON('http://www.atletismope.com.br/eventos/lista',  function(eventos) {
         $.each(eventos, function(index, evento) {
              canvasEvents["04-20-2015"] = '<a href="#" target=_blank>CAMPEONATOS SUL-AMERICANOS DE ATLETISMO</a>';
         });    
    });
    canvasEvents["04-25-2015"] = '<a href="#" target=_blank>CAMPEONATOS SUL-AMERICANOS DE ATLETISMO</a>';
When canvasEvents is added inside the looping does not work, but if we add outside the looping works. Why?
There is a plugin that uses this object, jquery.calendario.js. Assigning the object only works if I put an Alert out of the loop. Here is the code that is working. You can view the result in this url: http://www.atletismope.com.br/eventos/calendario
var canvasEvents = new Object;
$.getJSON('http://www.atletismope.com.br/eventos/lista',  function(eventos) {
    $.each(eventos, function(index, evento) {
        var data = evento.data;
        var data_f = data.substr(5,2) + '-' + data.substr(8,2) + '-' + data.substr(0,4);
        canvasEvents[data_f] = '<a href="#" target=_blank>'+ evento.titulo +'</a>';
    }); 
});
alert(canvasEvents); //nao funciona sem o alert
is sure that the code comes to be executed inside the loop?
– Marciano.Andrade
Jonas I saw that you put an answer following my idea/suggestion to put the code inside the callback. I’m glad you solved the problem. If you want you can mark as accept one of the answers.
– Sergio