Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8718523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:34:21+00:00 2026-06-13T06:34:21+00:00

I have a very basic issue, but cannot see a solution to it. Maybe

  • 0

I have a very basic issue, but cannot see a solution to it. Maybe I need to change my way of thinking. Basically I am getting a model back in the JSON file, but I can’t figure out how to convert true to checked. For example I know the {{-done}} is either true or false.

input type="checkbox"  id="chkName"   <%= {{-done}} ? "checked" : "" %>

I see loads of examples like this, but does not work for me. Is it because of the way I have brought back the true/false value.

Any help would be appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:34:22+00:00Added an answer on June 13, 2026 at 6:34 am

    Your problem is that you are using the wrong type of Underscore.js template tag, the tag you are using is for interpolating a value and having it HTML-escaped.

    To explain, there are three types of tags within underscore templates,

    1. <%= %> – Interpolate – Evaluates the data of the property and prints it.
    2. <%- %> Escape Evaluates the data and prints it HTML-escaped.
    3. <% %> Evaluate Allows you to execute JavaScript in your template.

    In addition when executing JavaScript within your template you can use the Print method to print out some text (for example the results of an attribute).

    Based on the above in your case you need to run a conditional within your template to print out checked if done evaluates to true. What you can therefore do is something like the following

    <% if(done) { %> 'checked="checked" <% } %>
    

    Or you can use the print method

    <% print(done ? 'checked="checked"' : '') %>
    

    Edit:

    Based on the template you posted, the following template should work

         <script id="item-template"  type="text/template">   
             <input type="checkbox" id="toggle" <% print( done ?  'checked="checked"' : '') %> /> 
               <span class="text">{{-done}}</span>
               <a id="dele" data-role="button" data-inline="true" data-icon='delete' >Delete</a>
            </script>
    

    Here is a link to a jsBin using the default ERB-style delimiters

    And here’s a second one using mustache style delimiters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some very basic semaphore code that works great on Linux, but cannot
I have a very basic databinding issue with the Visifire WPF charting tool in
This is probably very basic but I'm stalling ... On page load, I need
I'm writing a very basic Facebook app, but I'm encountering an issue with cross-domain
I realize that this is probably a very basic question, but I have spent
I have a very basic mysql table called memberships, that tracks which people belong
I have a very basic API in my app which also has an index
I have a very basic windows forms app, working in C#, and I was
I have a very basic app with two ignition-remoteimageviews (RIV) in them. The app
I have a very basic doubt regarding the method that gets executed when app

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.