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

367
Views
How to add attribute to div, when using Handlebars JS?

I am using Handlebars JS to add elements from a template. The Handlebar template looks like this:

<script id="item-template" type="text/x-handlebars-template">
    <div class="case-item">{{title}}</div> 
</script>

Script

// create a handlebars template
var source = document.getElementById('item-template').innerHTML;
var template = Handlebars.compile(source);

Dataset

var items = new vis.DataSet([{        
    title: 'This is a test title'
}

Result

When I run the code, the <div class="case-item"> only shows <div> it doesn't create the attribute class="case-item"

<div>This is a test title</div>

and not

<div class="case-item">This is a test title</div>

Any ideas why it "strips" the attribute?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I found another solution, to go around the Handlebar issue described in the question.

I chose to follow the Vis Timeline Custom Styling example

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!