Calling a jQuery plugin in a Backbone render method

前端 未结 5 1740
隐瞒了意图╮
隐瞒了意图╮ 2021-02-02 16:09

I have a render method in Backbone that goes basically like this:

render: function () {
  $.tmpl(this.template, attrs).appendTo(this.el);
  return this;
},
         


        
5条回答
  •  南笙
    南笙 (楼主)
    2021-02-02 16:43

    I was able to get this to work for my jQuery plugin only by specifying the context for jQuery in the render function:

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

提交回复
热议问题