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.
Somewhere you should have a line like this.That compiles your template into a function that you can pass your model data and generate html like so:
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
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…