0

これはコードの図です:http: //jsbin.com/uzapuy/1/edit

次のようなURLでテストにアクセスできるようにしたい:http: //jsbin.com/uzapuy/1#/test/2 entrieはすでにクライアント側に存在する可能性があるため、最初に、フェッチが欠落している場合にのみ確認したいサーバー側から。DS.Storeなしでそれは可能ですか?

4

1 に答える 1

0

あなたのTestRouteでは、次のようなことはできませんか?

App.TestRoute = Ember.Route.extend({

    model: function(params) {

        // Find your controller that has the "fetch" method.
        var testController = this.controllerFor('test');

        // Check if there's an existing model with this ID.
        var existingModel  = testController.find('id', params.id);

        // Determine if we found a model or not.
        if (existingModel) {

            // If we found an existing model, then we can set this as the model.
            return existingModel;

        }

        // Otherwise we'll fetch it from the server.
        return testController.fetch(params.id);
    }

});

また、コードでは、test変数はundefined次のようになることに注意してください。

var tests = App.Test.create({id: id, name: 'fetched ' + id});
self.set('content', test);

あなたは後testsだと思います。

于 2013-02-09T12:40:03.767 に答える