Backbone.js的收集和Tastypie过滤器 [英] Backbone.js Collection and Tastypie filters

查看:124
本文介绍了Backbone.js的收集和Tastypie过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不是检索记录整个表的骨干收集我定义的,我认为这是更有效的利用我创建了美味的馅饼过滤器。我将如何让骨干使用它们?据我了解,骨干型号/只集合点到模型的顶层URI。

Instead of retrieving the entire table of records for a Backbone collection I've defined, I reckon it's much more efficient to make use of the tasty-pie filters I've created. How would I let Backbone use them? As far as I understand, Backbone models/collections only point to the top-level URI of the model.

例如。我有在Django中定义的预订模式,可以通过/ API /预约的访问,但我想用/ API /预订?房= 3里的房间号是上下文特定的填充骨干集合。

e.g. I have a Bookings model defined in Django that can be accessed via "/api/booking" but i want to populate the Backbone Collection with "/api/booking?room=3" where the room number is context specific.

推荐答案

我发现,骨干.fetch()方法接受数据属性,就像JQuery的阿贾克斯()。

I've found out that backbone's .fetch() method accepts the "data" attribute just like JQuery .ajax().

booking.fetch({ data : { "room" : 3 } });

这篇关于Backbone.js的收集和Tastypie过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆