Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
alert firing but the function is ignored on my event listener

I am fairly new to writing code in general. it's only been a year since I started.

I have a website the pulls a pageant from firestore. If the pageant has different categories, it will display the categories allowing the client to choose the category first before displaying the candidates for that category.

The problem that I have is that when clicking on the category, the alert fires but the actual function is ignored. This only happens on IOS.

I have tried multiple solutions on here.

Added cursor:pointer.

added role="button" when I used a div first instead of a button.

I tried .on('click', and so on).

I tried .click().

I tried wrapping it $(document).ready().

This one is static <div id="main-content-container" class="main-content-container"></div>

const mainContentContainer = document.getElementById('main-content-container');

renderPageant()
async function renderPageant() {
    let html = `
        <div id="render-candidates-container" class="render-candidates-container"></div>
    `
    mainContentContainer.innerHTML = html;

    const renderCandidatesContainer = document.getElementById('render-candidates-container');

    const doc_1 = await db.collection('Pageants').doc(value).get();
    const category = doc_1.data().isCategory
    if(category == true) {
        const querySnapshot = await db.collection('Pageants').doc(value).collection('Categories').get();
        $('#render-candidates-container').empty();
        
        console.log(querySnapshot.size)
        querySnapshot.forEach((doc_2) => {
            const button = document.createElement('button');
            button.setAttribute('id', doc_2.id + '-category-image');
            button.setAttribute('class', 'cursorPointerClass')
            button.innerHTML = `
                <img src="${doc_2.data().categoryBanner}" alt="category banner">
            `
            renderCandidatesContainer.insertBefore(button, renderCandidatesContainer.childNodes[3]);

            const categoryImage = document.getElementById(doc_2.id + '-category-image');
            categoryImage.addEventListener('click', function() {
                alert('Fired!')
                var x = {
                    pageantID: doc_1.id,
                    categoryID: doc_2.id,
                    category: true,
                    ovarallVotes: doc_1.data().overallVotes
                }
                timerCandBlock(x);
            }) 
        })
        return
    }

    var x = {
        pageantID: doc_1.id,
        categoryID: 'undefined',
        category: false,
        ovarallVotes: doc_1.data().overallVotes
    }
    timerCandBlock(x);            
    return
}

timerCandBlock(x); works fine since it actually works when in Chrome PC or Chrome Android. It even works when in inside Facebook in-app browser. But it just does not work when in IOS.

What am I missing here?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda