Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

85
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!