Backbone.js and jQuery UI Accordion



我正在尝试从 Backbone.js 视图呈现的标记中创建一个 jQuery UI 手风琴小部件。我的视图代码如下:

var AccessPointAccordion = Backbone.View.extend({
  el: $("#access_point_accordion"),
  initialize: function() {
    this.collection = new AccessPoint(bootstrappedModels);
    this.render();  // renders the markup correctly
    this.$el.accordion();
  }
  .
  .
  .
});

当标记正确呈现时,它不会呈现为折叠构件,而只是保留为无样式标记。我是骨干.js新手,有人可以指出我是否犯了一个简单的错误以及如何解决它吗?

你可以在渲染函数中尝试一下:

render: function(){
    //template and other code
    setTimeout("this.$el.accordion();",0);
    return this;
}

最新更新