Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

354
Visualizações
jQuery click on leaflet map is working the first time, but not the second

EDIT : I have recreated the issue on this website, if you want to check : http://leafletdev1.id-interactive.info/

I am truely sorry, i saw a lot of posts that looks like my problem, but none of them are working as I think it is not exactly related on the same subject. I am pretty sure my issue is somehow linked to this : jQuery Click Working Once, not Twice, but... I am a real newbie in ajax, and I can't really understand everything of what is going on here...

I have a wordpress website that is using the freemium version of the plugin Leaflet Maps Marker v3.12.4. Here, I am displaying a map, with popups that open when I click the marker linked to them :

enter image description here

What I am trying to achieve, is that when I click on a "Bouton d'action" button, it click the marker in order to open the popup. And it is actually working, except that when I move on the map, zoom, dezoom, or do any actual action, the clicks won't work anymore, and no more popups will open.

enter image description here

Here is my code :

$(document).ready(function () {
    $('.marker1').click(function () {
        let d = 250;
        setTimeout(function () {
            let markersDOM = $('.leaflet-marker-pane img');
            let marker = null;
            let markerTitle = null;

            for (var i = 0; i < markersDOM.length; i++) {
                markerTitle = markersDOM[i];
                marker = markersDOM[i].getAttribute("title");
                if (marker === "marker1") {
                    $(markerTitle).click();
                }
            }
        }, d);
    });
});

Do you know what is happening here ? I am a little lost...

Thanks a lot for reading this.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda