无法更改 Backbone 中模型的标签名称

Unable to change the tagName of model in Backbone

我正在尝试为我正在创建的模型设置 tagName,但它不起作用。控制台中没有错误,它可以工作,但标签是 div,没有任何 class、模型中指定的 ID 或属性。

请帮忙。

jQuery(document).ready(function($) {

  // NOTE: Basic Model of template
  var ZcoBuilderModel = Backbone.Model.extend({
    tagName :  "span",
    className: "zco_builder_element",
    id : "1233",
    attributes : {
      "data-type": "template"
    },
    defaults: {
      en_header: false,
      en_title: false,
      en_Content: false,
      en_Footer: false,
      en_deletable: false,
      title: "",
      en_template_status: false,
      id_header : 0,
      id_title: 0,
      id_Content: 0,
      id_Footer: 0,
    },
    initialize: function() {
      console.log("Created");
    }
  });

  // NOTE: Collaction of templates
  var ZcoBuilderCollection = Backbone.Collection.extend({
    model: ZcoBuilderModel
  });

  // NOTE: View template for Single Model
  var ZcoBuilderView = Backbone.View.extend({
    render: function() {
      var zcoBuilderTemplate = _.template($('#zcoTemplate').html());
      var zcoBuilderTemplateHTML = zcoBuilderTemplate(this.model.toJSON());
      this.$el.html(zcoBuilderTemplateHTML);
      return this;
    }
  });

  // NOTE: View Template for Collection Model this will render above
  var ZcoBuilderViewCollection = Backbone.View.extend({
    render: function() {
      var self = this;

      this.model.each(function(e) {
        var n = new ZcoBuilderView({
          model: e
        });
        self.$el.append(n.render().$el);
      });
    }
  });

 // NOTE: defaults collection
  var zcoBuilderDefaults = new ZcoBuilderCollection(
    [
      new ZcoBuilderModel({
        title: "Global"
      }),
    ]
  );

  //Templates Rendering
  var zcoBuilder = new ZcoBuilderViewCollection({
    el: '#zco_list',
    model: zcoBuilderDefaults
  });
  $('#zco_list').html(zcoBuilder.render());


});

tagNameidclassNameelevents 等属性在 [= 中使用时具有 special meaning 15=],但是对于Model

没有用

将其从 ZcoBuilderModel 移至 ZcoBuilderView