小编Jur*_*van的帖子

Backbone.js - 在视图中过滤和显示集合数据的正确方法

我在开始时加载了大量任务.
我想根据所选列表/收件箱显示它们,这样每个列表都不会有额外的加载.

window.Task = Backbone.Model.extend({});

window.TasksCollection = Backbone.Collection.extend({
    model: Task,
    url: '/api/tasks',
    inbox: function() {
        return this.filter(function(task) {
            return task.get('list') == null;
        });
    },
    list: function(id) {
        return this.filter(function(task) {
            return task.get('list') == id;
        });
    }
});

window.tasks = new TasksCollection;

window.TaskView = Backbone.View.extend({
    tagName: 'li',
    template: _.template($('#item-template').html()),
    initialize: function() {
        _.bindAll(this, 'render', 'close');
        this.model.bind('change', this.render);
        this.model.view = this;
    },
    render: function() {
        $(this.el).html(this.template(this.model.toJSON()));
        this.setContent();
        return this;
    },
});

window.TasksView = Backbone.View.extend({
    el: '#todo-list',
    collection: tasks,
    initialize: function() {
        _.bindAll(this, …
Run Code Online (Sandbox Code Playgroud)

backbone.js

39
推荐指数
1
解决办法
3万
查看次数

停止记录ActionController :: RoutingError Rails 3.2

如何禁用ActionController :: RoutingError错误的日志记录?
我的生产日志文件中充满了搜索phpMyAdmin和其他东西的机器人.
然后忽略了真正的应用程序错误.
请帮忙.我正在运行Rails 3.2和Passenger.

在我的routes.rb中,我将所有其他网址映射到get ":code" => "shared#code",然后,如果没有找到,我会显示一个带有消息的页面.但是当机器人搜索网址时http://mywebsite.com/phpMyAdmin/index.php,会显示经典错误页面"您正在寻找的页面不存在.".哪个好.但我只是不想在日志文件中记录这些错误.

ruby-on-rails passenger ruby-on-rails-3

8
推荐指数
1
解决办法
1969
查看次数