0

I´m using underscore to load a html template with by require.js with text.js, like code bellow:

      template: _.template(listItemTemplate)    

      , render: function () {
            $(this.el).html(this.template(this.model.toJSON));
            return this;
        }

tvListItemTemplate.html

<h4><%= _id%></h4>

If i do console.log(this.model.toJSON()) it prints the following:

enter image description here

But the console give me this error:

enter image description here

I don´t understand why

2 Answers 2

1

Check with:

  $(this.el).html(_.template(listItemTemplate, this.model));

or

  template: function(x) {
      _.template(listItemTemplate, x);
  },
  render: function () {
        $(this.el).html(this.template(this.model));
        return this;
  }
0
0

Sorry for that but it was a own stupid error in:

$(this.el).html(this.template(this.model.toJSON()));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.