Backbone.js的提取结果缓存 [英] backbone.js fetch results cached

查看:84
本文介绍了Backbone.js的提取结果缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的获取:

App.Controllers.PlanMembers = Backbone.Controller.extend({
    routes: {
        "": "index"
    },

    index: function () {
        var planMembers = new App.Collections.PlanMembers();

        planMembers.fetch({
            success: function () {
                var recoveryTeam = planMembers.select(function (planMember) {
                    return planMember.get("TeamMemberRole") == "RecoveryTeam";
                });

                var otherMembers = planMembers.select(function (planMember) {
                    return planMember.get("TeamMemberRole") == "Other";
                });

                new App.Views.Index({ collection: { name: "Team", members: recoveryTeam }, el: $('#recoveryTeam') });

                new App.Views.Index({ collection: { name: "Team", members: otherMembers }, el: $('#otherTeam') });
            },
            error: function () {
                alert('failure');
                showErrorMessage("Error loading planMembers.");
            }
        });
    }
});

的问题是,对结果进行高速缓存。它不拿起数据库更改。反正是有告诉Backbone.js的不缓存结果?

The problem is that the results are being cached. It does not pick up database changes. Is there anyway to tell backbone.js not to cache the results?

我知道我可以覆盖集的URL,并附加时间戳,但我期待的东西比这一点更清洁。

I know I could override the url of the collection and append a timestamp but I am looking for something a bit cleaner than that.

推荐答案

这是IE浏览器通常是一个问题,骨干网无关吧。你必须深入到jQuery的Ajax调用,并期待在文档。骨干网使用jQuery AJAX其同步的方法。你可以做这样的事情,迫使所有的浏览器的AJAX调用:

This is a problem on IE usually and backbone has nothing to do with it. You have to go down to the jQuery ajax call and look at the doc. Backbone uses jquery ajax for its sync method. You can do something like this to force ajax call on all browsers:

$.ajaxSetup({ cache: false });

http://api.jquery.com/jQuery.ajaxSetup/

这篇关于Backbone.js的提取结果缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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