سؤال

I'm just starting to look at Ext Direct, and I'm trying to get namespaces to work with it. However, I'm not having much luck.

Following the documentation (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.direct.RemotingProvider-cfg-disableNestedActions) I tried this:

Ext.Direct.addProvider({
    url: 'router',
    type: 'remoting',
    actions: {
        TestAction: {
            name: 'foo',
            len:  1
        },
        'TestAction.Foo': {
            name: 'bar',
            len: 1
        }
    },
    namespace: 'MyApp'
});

MyApp.TestAction.Foo.bar();

However, I'm now getting the error 'object has no method bar'.

Does anyone know why this is happening?

Thanks

هل كانت مفيدة؟

المحلول

Methods definitions must be array of objects, not objects.

This way, no error:

Ext.Direct.addProvider({
    url: 'router',
    type: 'remoting',
    actions: {
        TestAction: [{ // <= Here, array!
            name: 'foo',
            len:  1
        }],
        'TestAction.Foo': [{
            name: 'bar',
            len: 1
        }]
    },
    namespace: 'MyApp'
});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top