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

  • SEARCH
  • Home
  • 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 3303708
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:59:07+00:00 2026-05-17T20:59:07+00:00

I have a setup like this… $(document).ready(function(){ var model = { /* some variable

  • 0

I have a setup like this…

$(document).ready(function(){ 
  var model = { /* some variable names */, Traits[] };
  var traits = // json array pulled from server.

  $('input[type=checkbox]').button(); // jquery ui button control.
});

Now, in my HTML, I have a jQuery Template like this.

{{each(i, trait) traits}}
   <input type='checkbox' id='chk${trait.Name}' />
   <label for='chk${trait.Name}'>${trait.Name}</label>
{{/each}}

Now, when I am creating things using this style, it works great. But when I go to edit things, I want the ‘Traits’ that have already been picked to be ‘checked’ by default. So I tried this code..

// jquery startup... variable loading, etc.
function evaluateCheckbox(item){
   $("'#chk" + item.Name + "'").attr('checked', true);
}
model.Traits.forEach(evaluateCheckbox);

Not only does this not check the boxes, but it then creates every checkbox twice. I don’t understand why this is. Can anyone give me some insight, and an idea on how to fix it?

  • 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-05-17T20:59:08+00:00Added an answer on May 17, 2026 at 8:59 pm

    You have an extra set of qoutes in there, it should just be:

    $('#chk' + item.Name).attr('checked', true);
    

    You probably want to refresh the jQuery UI button’s visible state afterwards as well, like this:

    $('#chk' + item.Name).attr('checked', true).button('refresh');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some HTML setup like this: <div> <label for=amount><a id=amount-help-icon class=help icon-link href=#><span
in my users model I have a paperclip setup like this: has_attached_file :profile_pic, :styles
In a Cocoa app, I have a setup like this: The main thread (M)
We have a cloud setup like this: User Request -> Perlbal (SSL unwrapping) ->
Assuming you have a project setup like this: -WebApp |_ requirements.txt |_ bootstrap.py (virtualenv
I have an MVC solution setup like this, with three 'projects'. Web (MVC Project,
So I have this iPhone app with a nested setup like this: [RootViewController]->[UITabBarController]->[UINavigationController]->[subViewControllers]. Everything
A have setup an internal proxy kind of thing using Curl and PHP. The
I'm having an issue trying to append a javascript file using headScript()->appendFile('file name') with

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.