Backbone.js使用子文件夹获取url

时间:2012-08-01 12:37:38

标签: backbone.js

所以我使用backbone.js就像这样:

window.TicketCollection = Backbone.Collection.extend({
    model:Tickets,
    url:"/index.php/tickets/viewJSON"
});

根据我希望传递子文件夹的页面,如下所示:

ticketList.fetch({ data: "a1103" });

然后将附加到url并从以下内容中获取数据:

/index.php/tickets/viewJSON/a1103

这怎么可能?

1 个答案:

答案 0 :(得分:1)

window.TicketCollection = Backbone.Collection.extend({
    subFolder : 'defaultFolder',

    url:function(){
        return "/index.php/tickets/viewJSON/" + this.subFolder;
    }
});

var some = new window.TicketCollection();
some.subFolder = 'a1103';
some.fetch();