-1

我正在尝试在 Firebase(Backfire)为我的骨干应用程序提供数据时插入加载消息/图标,但它现在运行良好,这里有一个小例子:http: //jsfiddle.net/aJfUx/5 /

我在渲染数据时尝试添加和删除 HTML 元素,但它不起作用:

render: function() {
    this.$el.html("<i class='icon-spin icon-refresh loading-icon' />");
    this.collection.each(function( item ){
    this.renderBook( item );
    }, this);
    this.$el.find(".loading-icon").remove();
}

我的目标是仅在呈现所有内容后才显示所有数据。

4

1 回答 1

0

I take it that renderBook takes a long time and you try to prevent the user seeing how it's built. I'd create a element and populate it without it being part of the DOM yet.

render: function() {
    this.$el.html("<i class='icon-spin icon-refresh loading-icon' />");
    var $panel = $('<div></div>');
    this.collection.each(function(item) {
      this.renderBook(item, $panel);
    }, this);
    this.$el.html($panel);
}
于 2013-09-08T12:02:56.437 回答