R
R
rimlin2015-07-30 00:29:24
backbone.js
rimlin, 2015-07-30 00:29:24

How to fix [Object object] when compiling Handlebars in Backbone?

Let's say we have the following trivial application: pastebin.com/f7A12eKE
When the page is rendered, the following text is displayed: [Object object]
But if in line 31 we change it to:

this.$el.html(this.template({ value: this.section.render().$el.html() }));

then the text of the template with the inserted data will be displayed. I noticed that Module renders normally and renders the template as it should, and Section produces either [Object object] or template text in the second variant.
How to make the template fit into the document normally?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2015-08-12
@alexey-m-ukolov

It all depends on what's going on in your template.
A template is just a function that takes arguments. You pass either a jQuery object in the value key in the first case (and, apparently, you do somewhere toString, which just returns [Object object]), or an html string in the second case.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question