Javascript 在backgrid表中输入标记

Javascript 在backgrid表中输入标记,javascript,jquery,backbone.js,backgrid,Javascript,Jquery,Backbone.js,Backgrid,我在表中创建了自定义标记单元格,并实现了 所以我的手机看起来像: var TagCell = Backgrid.TagCell = Cell.extend({ className: "tag-cell", events: { 'click .tag a': 'removetag', }, initialize: function (options) { TagCell.__super__.initialize.apply(this, arguments);

我在表中创建了自定义标记单元格,并实现了

所以我的手机看起来像:

var TagCell = Backgrid.TagCell = Cell.extend({
  className: "tag-cell",
  events: {
      'click .tag a': 'removetag',
    },
  initialize: function (options) {
    TagCell.__super__.initialize.apply(this, arguments);
    this.title = options.title || this.title;
    this.target = options.target || this.target;
    var model = this.model;
    var rawData = this.formatter.fromRaw(model.get(this.column.get("name")), model);


  },
  removetag: function(event) {
      var that = this;
      that.model.set({location: ""},{success: alert("removed!"));

  },
  render: function () {
    this.$el.empty();
    var rawValue = this.model.get(this.column.get("name"));
    var formattedValue = this.formatter.fromRaw(rawValue, this.model);
    this.$el.append('<input name="location" class="tagggs" value="'+formattedValue+'" />');
    this.delegateEvents();
    return this;
  },
});
如果我试图调用带有事件的removetag函数,请单击以保存带有空位置的标记模型。但如果我试图用click event调用函数,则不会调用.tag a或直接调用class.rmvtag函数。我认为,因为jquery标记输入是这样设计的:

 $('<span>').addClass('tag').append(
     $('<span>').text(value).append('&nbsp;&nbsp;'),
     $('<a>', {
         href  : '#',
         class : 'rmvtag',
         text  : 'x'
     }).click(function () {
         return $('#' + id).removeTag(escape(value));
     })
 ).insertBefore('#' + id + '_addTag');
所以有一个click函数,它的removetag直接写在append元素之后。如何在单击rmvtag链接时从主干调用save model函数?
谢谢你的帮助

使用jQuery创建的视图和视图之间的关系是什么?何时将该元素附加到DOM?请查看此处并尝试检查标记。Span用于使文本看起来像标记。我看不出您在视图中的何处或何处附加此块。你能告诉我这是什么时候插入DOM的吗?