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

221
Visualizações
How to launch function every time part of page reloads

i am making app in Django and i would like to launch function every time that i reload calendar. When user clicks arrows on the side of calendar it reloads division with calendar and shows new month. When user clicks on one of the days new content should show up (this is done by assigning content to each day using setAttribute("onclick", ...) function). Content showing works until i change month. From what i understand it is because i assign function to only existing DOM elements and not the new ones. I tried assigning it to new elements in various ways but it never worked. Is there some way to do it?

Month changing is done by ajax load function.

for (var x=0; x < days.length; x++) {
    days[x].setAttribute("onclick", `setDay(
    "${String(days[x].innerHTML)}",
    "${(month[1].innerHTML)}"
    )
`)}

$('#right').click(function () {
    let mth = $('.month')[1].innerHTML.split(" ")
    let month = parseInt(monthsObj[mth[0]])+1
    let year = parseInt(mth[1])
    if (month == 13) {
        month = 1
        year += 1
        $('#newCal').html('').load(
            "{% url 'calendarChange' monthNumber=4 yearNumber=2022 %}".replace("4", month).replace("2022", year)
        );
        } else {
        $('#newCal').html('').load(
            "{% url 'calendarChange' monthNumber=4 yearNumber=2022 %}".replace("4", month).replace("2022", year)
        );
    }
})

I tried putting that for cycle in function and putting it into ajax click. Ajax click then worked but for cycle didn't.

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