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

86
Visualizações
Manipulating the output of variables in Django with JavaScript function

I use this piece of code to grab part of the description from video object:

        <div id="description">
            <p>{{video.description | slice:":20" }}</p>
            <button onclick="showDescription()">Show description</button>
        </div>

There I got showDescription() function, I want it to display the rest of the description by changing the inner HTML code:

function showDescription() {
    var text = document.getElementById('description')
    text.innerHTML = "<p style='overflow-wrap: break-word; width: 100%;'>{{video.description}}</p>"
};

But it returns

{{video.description}}

Instead of actual description, any thoughts?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need to pass {{video.description}} as a function argument.

<div id="description">
    <p>{{video.description | slice:":20" }}</p>
    <button onclick="showDescription('{{video.description}}')">Show description</button>
</div>

function showDescription(description) {
    var text = document.getElementById('description')
    text.innerHTML = "<p style='overflow-wrap: break-word; width: 100%;'>" + description + "</p>"
};
about 4 years ago · Juan Pablo Isaza Relatório
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