0

I have this code in backbone.js:

render: function(type) {
  var html = _.template($('#book-page-template-type-'+type).html(), this.model.toJSON());
  this.$el.html(html); 
  return this;
}

Were the type dynamically creates different versions of a web form template. That works great and I can render the view successfully.

But when I am trying to save changes made in the view to the server:

  save: function(){
  var text = this.$("#page-title").val();
  var content = this.$("#page-content").val();
  this.model.set({"title":text,"content":content});
  this.model.save();
}

I am getting this error:

Error: Syntax error, unrecognized expression: #book-page-template-type-[object Object]

Which obviously refers to the template name. (BTW the error is coming from jQuery).

Why is that happening ?

4

0 回答 0