简体   繁体   English

为什么我的自定义ember-data适配器出现此错误:无法调用未定义的方法'lookupFactory'

[英]Why am I getting this error with my custom ember-data adapter: Cannot call method 'lookupFactory' of undefined

I am just starting out with Ember and using the docs at http://emberjs.com/api/data/classes/DS.Adapter.html to create a custom adapter for accessing a SOAP web service. 我刚刚开始使用Ember并使用http://emberjs.com/api/data/classes/DS.Adapter.html上的文档来创建用于访问SOAP Web服务的自定义适配器。 When I try to access the store that uses this adapter, however, I get this error: 但是,当我尝试访问使用此适配器的商店时,出现此错误:

TypeError: Cannot call method 'lookupFactory' of undefined

Here's my code: 这是我的代码:

App = Ember.Application.create();

App.RMSoapAdapter = DS.Adapter.extend({

    find: function(store, type, id) {
        switch(type) {
        case 'group-mailbox':
            return getGroupMailboxForStore(id, store);
            break;
        default:
            throw 'Unknown object type: ' + String(type);
            break;
        }
    }
});

App.store = DS.Store.create({
  adapter: App.RMSoapAdapter.create(),
});


App.IndexRoute = Ember.Route.extend({
  model: function() {
    var store = App.store;
      return store.find('group-mailbox');
  }
});

That documentation is a little wonky, that's if you want to set up a different store etc, but if you are wanting to use the built in store you would do it like this. 那个文档有点不稳定,如果你想设置一个不同的商店等,但如果你想使用内置商店,你会这样做。

App.ApplicationAdapter = App.RMSoapAdapter;

App.IndexRoute = Ember.Route.extend({
  model: function() {
      return this.store.find('group-mailbox');
  }
});

And the type must be a valid DS model, it's looking up the group-mailbox and it's going to send in App.GroupMailbox, not the string. 并且类型必须是有效的DS模型,它正在查找group-mailbox ,它将在App.GroupMailbox中发送,而不是字符串。

App.GroupMailbox = DS.Model.extend({

});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Ember-data“无法调用方法'hasOwnProperty'未定义” - Ember-data “Cannot call method 'hasOwnProperty' of undefined” 灰烬数据自定义适配器 - Ember-Data Custom Adapter 使用Fixture Adapter将js对象切换到Ember Data模型,并不断收到“无法调用未定义的方法'findAll'”错误 - Switched over js object to Ember Data model using Fixture Adapter and keep getting “Cannot call method 'findAll' of undefined” error 为什么ember-data 2.7.0 normalizeHelper期望来自我的自定义适配器的JSON API响应? - Why is ember-data 2.7.0 normalizeHelper expecting a JSON API response from my custom adapter? 什么时候编写自定义的ember-data适配器? - When to write custom ember-data adapter? 无法调用在余烬数据关系上保存 - Cannot call save a on an ember-data relation Ember数据夹具适配器 - Ember-Data Fixture Adapter 灰烬{{#with…controller =…}}给出“未捕获的TypeError:无法读取未定义的属性'lookupFactory'” - Ember {{#with … controller=…}} gives “Uncaught TypeError: Cannot read property 'lookupFactory' of undefined” Ember,Ember-data和Rails关系错误:“无法读取未定义的属性'typeKey'” - Ember, Ember-data and Rails relations error: “Cannot read property 'typeKey' of undefined” 使用自定义Ember-Data REST适配器进行PUT请求 - PUT requests with Custom Ember-Data REST Adapter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM