2012-09-24 38 views
0

我有这样的代码在我的路由器:Backbone.js的 - 网址:ID没有获得通过到循环

category: (id) -> 
    alert id 
    filteredProducts = new App.Collections.Products(@productsCollection.where({category_id: id})) 
    @productsView.renderResults(filteredProducts) 

alert id调用工作正常(如app.com/categories/6>警报“6” ),当我在where功能改变id到实际数量的产品收集过滤正常,像这样:

filteredProducts = new App.Collections.Products(@productsCollection.where({designer_id: 6})) 

但是,当我设置designer_id: id的地方环路返回一个空的集合。

+0

难道是你在第二个调用'Altar.Collections.Pieces',但是第一个调用'App.Collections.Pieces'? – tkone

+0

不,不是。我的应用程序被命名为祭坛,但为了减少我在我的帖子中将Altar重命名为App的混淆,但忘记在第二次调用中更改它。我的错!更改了原始帖子以更正此问题。 –

回答

0

我的外键category_id是一个不是字符串的数字。答案是:

filteredProducts = new App.Collections.Products(@productsCollection.where({category_id: parseInt(id)}))