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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:12:03+00:00 2026-06-02T07:12:03+00:00

I am using the normal way of creating html bits by combining backbone.js and

  • 0

I am using the normal way of creating html bits by combining backbone.js and underscore.js. This is an example from what I use

_.template($('#html-container').html(), this.model.toJSON());

And I append this where I need it. The model in this case is a normal backbone model.

Now the HTML that this ouputs looks like this:

<li _id="4f82f7c3c5de997ad3fd4989" code="61131" unit="100ml" op="11" rp="22" cp="0" id="4f82f7c3c5de997ad3fd4989">

Basically it created a html attribute for each variable in my Model. Is this normal or am I doing something wrong here.

  • 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-02T07:12:07+00:00Added an answer on June 2, 2026 at 7:12 am

    Somewhere you should have a line like this.

    var sometemplate = _.template($('#html-container').html());
    

    That compiles your template into a function that you can pass your model data and generate html like so:

    var html =  sometemplate(this.model.toJSON());
    

    You’re trying to do it all on one line.. which you could do (not this way though), but it’s best to compile the template once, save a reference to that somewhere and refer to it later.

    See also http://documentcloud.github.com/underscore/#template

    EDIT: and now that I did see it, I see

    If you’re writing a one-off, you can pass the data object as the
    second parameter to template in order to render immediately instead of
    returning a template function.

    so that’s ok. So, perhaps either you’re including more than one latyer off data when your JSONable object is generated (I mean, you have an object within your object or something), or…

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

Sidebar

Related Questions

I have started to look away from the normal MVC way of creating my
I am using .Net 2 and the normal way to store my settings. I
Right, perhaps I should be using the normal Python lists for this, but here
A friend of mine has to send a normal email using ONLY HTML/HTML5 (or
I'm writing a small function to generate values from the Normal distribution using Box-Muller
I'm creating a little game using Three.js and everything is going well apart from
I am creating a web-application which lets you select a template from the template
I'm using an EAGL context and view for my application's normal screen rendering. This
Creating a website using simple html(not html5) and css but got stock in mouseover
Logged into my Windows XP SP2 computer using my normal user account (which has

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.