Backbone.js - 集合上的淘汰风格渲染

发布于 2025-01-04 03:46:51 字数 360 浏览 0 评论 0 原文

这两个框架都很棒,但我注意到 Knockout 喜欢指出它能够仅渲染添加到列表中的最新项目 - 而不是渲染整个列表。当然,这对于大型应用程序来说是性能增强器。

这是我正在谈论的示例(请务必选中“显示渲染时间”框): http://knockoutjs.com/examples/collections.html

但是,这似乎是任何主要的 javascript 框架都会有的东西 - 因为它是如此重要。

那么这个功能是否也融入到 Backbone 中,我将如何实现它?

Both of these frameworks are great, but I've noticed that Knockout likes to point out that it has the ability to render only the newest items that are added to a list - instead of rendering the whole list. Which, of course, is a performance booster for larger apps.

Here is an example of what I'm talking about (be sure to check the 'show render times' box): http://knockoutjs.com/examples/collections.html

But, this seems like something that any major javascript framework would have - since it is so important.

So is this feature also baked into Backbone, and how would I go about implementing it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泛滥成性 2025-01-11 03:46:51

以下是执行此操作的主干示例。

http://documentcloud.github.com/backbone/examples/todos/index.html

...
    initialize: function() {
      this.input    = this.$("#new-todo");
      Todos.bind('add',   this.addOne, this);
    },


    // Add a single todo item to the list by creating a view for it, and
    // appending its element to the `<ul>`.
    addOne: function(todo) {
      var view = new TodoView({model: todo});
      $("#todo-list").append(view.render().el);
    },
...

The following is a backbone sample that does just that.

http://documentcloud.github.com/backbone/examples/todos/index.html

...
    initialize: function() {
      this.input    = this.$("#new-todo");
      Todos.bind('add',   this.addOne, this);
    },


    // Add a single todo item to the list by creating a view for it, and
    // appending its element to the `<ul>`.
    addOne: function(todo) {
      var view = new TodoView({model: todo});
      $("#todo-list").append(view.render().el);
    },
...
可遇━不可求 2025-01-11 03:46:51

我最近遇到了这个,它正是我正在寻找的: https://github.com/derickbailey/ backbone.modelbinding

Derick Bailey 是一位非常熟练的 JavaScript 开发人员,这里是他撰写的有关 Backbone 模型绑定的随附文章:
http://lostechies.com/derickbailey/ 2011/07/24/awesome-model-binding-for-backbone-js/

希望对其他人有帮助。

编辑


Derick还有一个用于Backbone的复合框架,以帮助减少样板代码:http://lostechies.com/derickbailey/2011/12/16/composite-javascript-applications-with-backbone-and-backbone-marionette/

I recently ran across this, which does exactly what I was looking for: https://github.com/derickbailey/backbone.modelbinding

Derick Bailey is a VERY proficient JavaScript developer and here is an accompanying article that he wrote about model-binding for Backbone:
http://lostechies.com/derickbailey/2011/07/24/awesome-model-binding-for-backbone-js/

Hope it's helpful to someone else.

EDIT


Derick also has a composite framework for Backbone to help reduce boilerplate code: http://lostechies.com/derickbailey/2011/12/16/composite-javascript-applications-with-backbone-and-backbone-marionette/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文