骨干集合获取不处理参数

时间:2016-09-17 22:45:29

标签: javascript backbone.js

我希望用这种格式的“项目”(属性)显示待办事项:

-----------------------------------------
Project: Project1
Task            Due         Priority    Delegated
task1           9/18 @500p  A       Roy
task2           9/18 @500p  A       Roy
task3           9/18 @500p  A       Roy
-----------------------------------------
Project: Project2 
Task            Due         Priority    Delegated
task1           9/18 @500p  A       Maggie
task2           9/18 @500p  A       Maggie
task3           9/18 @500p  A       Maggie
-----------------------------------------

这样我就可以访问客户端的集合/模型以便在每个项目中进行排序,我想用params“completed”获取:false,然后使用下划线_.groupBy,但是fetch忽略了params并返回集合中的所有模型。

var todosCol = new TodosCol();
todosCol.fetch( {
    // processData: true, // no effect
    // traditional: true, // no effect
    // data:    $.param( { "completed": false } ) // no effect
    data: { "completed": false }
} );
var groups = _.groupBy( todosCol.models, function( model ){
    return model.get( "project" );
} );

我的收藏:

define( function( require ){

    var $               = require( "jquery" ),
    Backbone            = require( "backbone" ),
    _               = require( "underscore" ),
    bootstrap           = require( "bootstrap" ),
    LocalStorage            = require( "LocalStorage" ),

    TodoModel           = require( "home/HomeContentTodoModel" );

    return Backbone.Collection.extend( {
        model:          TodoModel,
        localStorage:       new Store( "todos" )
    } );

} );

Insight非常感谢。

0 个答案:

没有答案