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 9093683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:09:51+00:00 2026-06-16T23:09:51+00:00

I am building a web-application where I want to display a complex model (named

  • 0

I am building a web-application where I want to display a complex model (named Answer). I am using a Mustache template to format the data, but now I have the problem that I cannot attach any complex data to the resulting html, which is normally possible using jQuery’s .data() method.

My current (incorrect) implementation should demonstrate what I am trying to accomplish:

// (part of) the template
{{#answers}}
    <input type="checkbox" data-answer="{{.}}">{{text}}
{{/answers}}

// js on the page
$(document).on('change', 'input[type="checkbox"]', function (event) {
    console.log($(this).data('answer'));
})

Now I was hoping for a reference to the original Answer-object in the console, instead I got the rather useless string “[object Object]”. Is there some way for me to retrieve the original object when the user checks the checkbox?

Edit: See also http://jsfiddle.net/sebastianv89/jQBpN/

  • 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-16T23:09:52+00:00Added an answer on June 16, 2026 at 11:09 pm

    I think the problem may be that HTML data- attributes are used to store textual data, not actual Javascript objects, so using a Mustache template to attempt to set data-answer will only result in the text representation of your answer objects being stored

    Another approach you could try is to cache your answer objects in a map (as a JS object) and use your data-answer attribute to store keys into that map.

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

Sidebar

Related Questions

I'm building a web application and eventually would want to use Yii framework. But
I'm building a web-application in JavaScript using the dojo framework. I want to create
I'm building a web application and I have a question. I want to display
I'm building a web application using the default master template in VS2010 - very
I am building an ASP.Net web application and want to access data from MongoDB
I'm building a web application with Grails, using the Acegi/Spring Security plugin. I want
I'm building an application that harvests data from the web. But if there is
I am building web application using Spring MVC Spring Security Hibenate MySQl I want
I'm building an as3 only web application and want to be able to include
I am building a new asp.net MVC3 web application for reporting and I want

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.