相关疑难解决方法(0)

将backbone.js与ASPNET MVC集成是否有意义?

我不是这些构建模块的专家,但乍一看,在我看来:

  • ASPNET MVC希望在服务器端生成视图并管理应用程序的模型.它将浏览器视为一个有点愚蠢的表示引擎,是服务器为其提供的视图的消费者.

  • backbone.js想生成视图并在浏览器中管理模型.它将服务器端视为一个相当愚蠢的基于REST的持久性引擎.

这看起来像一个简单的观点.我确定这不是全部故事.

整合这两件事的真正机会是什么?这样做有意义吗?或者它们之间是否有太多重叠才有意义?

如果有人可以推荐我,我希望看到一些分析或讨论.

asp.net-mvc backbone.js

66
推荐指数
1
解决办法
7272
查看次数

Backbone.js:从集合中删除项目

我正在使用backbone.js来实现一个名为Roster的好友列表.我对名册收集和个人的主干观点rosterEntry如下:

    Slx.Roster.Views.RosterEntry = Backbone.View.extend({
    tagName: "li",
    className : "rosterEntry clearfix",
    templateSelector: '#rosterEntryTemplate',

    initialize: function() {
        _.bindAll(this, 'render');
        this.model.bind('change', this.render);
        this.model.bind('remove', this.remove);
        this.template = _.template($("#rosterEntryTemplate").html());
    },

    remove: function () {
        debug.log("Called remove event on model");
        $(this.el).remove();
    },
    render: function() {
        var renderedContent = this.template(this.model.toJSON());
        this.id = this.model.Id;
        $(this.el).attr('id', "friendid-" + this.model.get("id")).html(renderedContent);
        return this;
    }
});

    Slx.Roster.Views.Roster = Backbone.View.extend({
        el: "div#roster-container",
        initialize: function () {
            _.bindAll(this, 'render', 'add', 'remove');
            this.template = _.template($("#rosterTemplate").html());
            this.collection.bind('reset', this.render);
            this.collection.bind('add', this.add);
            this.collection.bind('remove', this.remove);
        },
        add: …
Run Code Online (Sandbox Code Playgroud)

javascript backbone.js

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

backbone.js ×2

asp.net-mvc ×1

javascript ×1