How to implement delete per row for backgrid

后端 未结 2 1898
逝去的感伤
逝去的感伤 2021-02-04 20:43

I\'ve been trying to implement a \"delete\" button for backgrid rows. A solution seems to be described here:

How to add a custom delete option for backgrid rows

相关标签:
2条回答
  • 2021-02-04 21:25

    You are getting an exception because your trying to call the function on the wrong view property. Backbone views have two different ways to access it's el, either directly in the DOM or as a jQuery object as follows:

    1. this.el - This is a direct reference to the DOM element.
    2. this.$el - The jQuery object for the DOM element.

    Its important to remember, that you need to call functions like append() and html() on the $el property as they are jQuery functions.

    0 讨论(0)
  • 2021-02-04 21:34

    dcarson is correct of course but just to very plainly spell out the code for the render function that I was able to use to get this to work correctly, with this.$el substitued for this.el:

    render: function () {
        this.$el.html(this.template());
        this.delegateEvents();
        return this;
    }
    
    0 讨论(0)
提交回复
热议问题